mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-12-04 11:29:05 +01:00
201 lines
7.9 KiB
YAML
201 lines
7.9 KiB
YAML
name: Mobile EAS Preview Build
|
|
|
|
# One preview client and its build record, called per platform by
|
|
# mobile-eas-preview.yml. The build job runs dependency and build scripts with a
|
|
# read-only token. Only the record job, on a fresh runner that runs none of
|
|
# them, gets the token that can push tags. The caller's concurrency group covers
|
|
# both jobs, so a build queued for the same fingerprint starts after the tag exists.
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
platform:
|
|
description: android or ios
|
|
required: true
|
|
type: string
|
|
fingerprint:
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
EXPO_PREVIEW_TOKEN:
|
|
required: true
|
|
outputs:
|
|
client:
|
|
description: Install link for the client with this fingerprint
|
|
value: ${{ jobs.android.outputs.client || jobs.ios.outputs.client }}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
android:
|
|
name: Build
|
|
if: inputs.platform == 'android'
|
|
runs-on: blacksmith-32vcpu-ubuntu-2404
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
|
|
# Set only by a new build: the tag message, which is the install link.
|
|
record: ${{ steps.build.outputs.link }}
|
|
env:
|
|
APP_VARIANT: preview
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
MOBILE_VERSION_POLICY: fingerprint
|
|
EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
|
|
FINGERPRINT: ${{ inputs.fingerprint }}
|
|
BUILD_TAG: mobile-android-preview-build/${{ inputs.fingerprint }}
|
|
# Phones only: emulators use the development client from the native-client cache.
|
|
ORG_GRADLE_PROJECT_reactNativeArchitectures: armeabi-v7a,arm64-v8a
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- id: record
|
|
name: Check build record
|
|
run: |
|
|
if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
|
|
echo "built=true" >> "$GITHUB_OUTPUT"
|
|
echo "link=$(git tag -l --format='%(contents:subject)' "$BUILD_TAG")" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
# The steps below run dependency and build scripts; they get no token.
|
|
- name: Drop checkout credentials
|
|
uses: ./.github/actions/drop-checkout-credentials
|
|
|
|
- name: Build
|
|
if: steps.record.outputs.built != 'true'
|
|
uses: ./.github/actions/eas-local-build
|
|
with:
|
|
platform: android
|
|
profile: preview:dev
|
|
environment: preview
|
|
expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
|
|
output: ${{ runner.temp }}/t3code-preview.apk
|
|
|
|
# `eas upload` hosts the APK on EAS and returns the page testers install from.
|
|
- id: build
|
|
name: Upload
|
|
if: steps.record.outputs.built != 'true'
|
|
working-directory: apps/mobile
|
|
shell: bash
|
|
run: |
|
|
eas upload --platform android --build-path "$RUNNER_TEMP/t3code-preview.apk" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
|
|
link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
|
|
if [ -z "$link" ]; then
|
|
echo "::error::eas upload returned no install link"
|
|
exit 1
|
|
fi
|
|
echo "link=$link" >> "$GITHUB_OUTPUT"
|
|
echo "### Android preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
ios:
|
|
name: Build
|
|
if: inputs.platform == 'ios'
|
|
runs-on: blacksmith-12vcpu-macos-27
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
|
|
# Set only by a new build: the tag message, the install link and profile expiry.
|
|
record: ${{ steps.profile.outputs.record }}
|
|
env:
|
|
APP_VARIANT: preview
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
MOBILE_VERSION_POLICY: fingerprint
|
|
EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
|
|
FINGERPRINT: ${{ inputs.fingerprint }}
|
|
BUILD_TAG: mobile-ios-preview-build/${{ inputs.fingerprint }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
|
|
with:
|
|
node-version-file: package.json
|
|
|
|
- id: record
|
|
name: Check build record
|
|
run: |
|
|
if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
|
|
link="$(git tag -l --format='%(contents)' "$BUILD_TAG" | node .github/scripts/mobile-ios-preview-record.cjs read)"
|
|
if [ -n "$link" ]; then
|
|
echo "built=true" >> "$GITHUB_OUTPUT"
|
|
echo "link=$link" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
fi
|
|
|
|
# The steps below run dependency and build scripts; they get no token.
|
|
- name: Drop checkout credentials
|
|
uses: ./.github/actions/drop-checkout-credentials
|
|
|
|
- name: Build
|
|
if: steps.record.outputs.built != 'true'
|
|
uses: ./.github/actions/eas-local-build
|
|
with:
|
|
platform: ios
|
|
profile: preview:dev
|
|
environment: preview
|
|
expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
|
|
output: ${{ runner.temp }}/t3code-preview.ipa
|
|
|
|
# EAS hosts the signed client and returns its install page.
|
|
- id: build
|
|
name: Upload
|
|
if: steps.record.outputs.built != 'true'
|
|
working-directory: apps/mobile
|
|
shell: bash
|
|
run: |
|
|
eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
|
|
link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
|
|
if [ -z "$link" ]; then
|
|
echo "::error::eas upload returned no install link"
|
|
exit 1
|
|
fi
|
|
echo "link=$link" >> "$GITHUB_OUTPUT"
|
|
echo "### iOS preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
# The tag stores the install link and provisioning-profile expiry.
|
|
- id: profile
|
|
name: Read the provisioning profile
|
|
if: steps.record.outputs.built != 'true'
|
|
env:
|
|
LINK: ${{ steps.build.outputs.link }}
|
|
run: |
|
|
profile_path="$(unzip -Z -1 "$RUNNER_TEMP/t3code-preview.ipa" | grep -E '^Payload/[^/]+\.app/embedded\.mobileprovision$')"
|
|
unzip -p "$RUNNER_TEMP/t3code-preview.ipa" "$profile_path" > "$RUNNER_TEMP/preview.mobileprovision"
|
|
security cms -D -i "$RUNNER_TEMP/preview.mobileprovision" > "$RUNNER_TEMP/preview-profile.plist"
|
|
record="$(node .github/scripts/mobile-ios-preview-record.cjs create "$LINK" "$RUNNER_TEMP/preview-profile.plist")"
|
|
echo "record=$record" >> "$GITHUB_OUTPUT"
|
|
|
|
# The tag is the record later runs look up. Android's message is the install
|
|
# link and is never replaced; iOS replaces an expired record for the fingerprint.
|
|
record:
|
|
name: Record build
|
|
needs: [android, ios]
|
|
if: ${{ !cancelled() && (needs.android.outputs.record != '' || needs.ios.outputs.record != '') }}
|
|
runs-on: blacksmith-2vcpu-ubuntu-2404
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: write # pushes the build record tag
|
|
steps:
|
|
# The commit the build job built. No build ran in this checkout.
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Record build
|
|
uses: ./.github/actions/record-build-tag
|
|
with:
|
|
tag: mobile-${{ inputs.platform }}-preview-build/${{ inputs.fingerprint }}
|
|
message: ${{ needs.android.outputs.record || needs.ios.outputs.record }}
|
|
replace: ${{ inputs.platform == 'ios' }}
|
|
token: ${{ github.token }}
|