Repository navigation
fix(mobile): Compose without a project opens the picker in one push #122493
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Mobile EAS Preview | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, labeled] | |
| permissions: | |
| contents: read | |
| jobs: | |
| ios: | |
| name: EAS Preview (iOS) | |
| if: | | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment') && | |
| (github.event.action != 'labeled' || github.event.label.name == '🚀 Mobile Continuous Deployment') | |
| runs-on: blacksmith-8vcpu-ubuntu-2404 | |
| concurrency: | |
| group: mobile-eas-preview-ios-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| outputs: | |
| group: ${{ steps.update.outputs.group }} | |
| client: ${{ steps.client.outputs.link }} | |
| build: ${{ steps.client.outputs.build }} | |
| fingerprint: ${{ steps.client.outputs.fingerprint }} | |
| env: | |
| APP_VARIANT: preview | |
| NODE_OPTIONS: --max-old-space-size=8192 | |
| MOBILE_VERSION_POLICY: fingerprint | |
| EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }} | |
| GH_TOKEN: ${{ github.token }} | |
| PR: ${{ github.event.pull_request.number }} | |
| steps: | |
| - id: expo-token | |
| name: Check for EXPO_PREVIEW_TOKEN | |
| run: | | |
| if [ -n "$EXPO_TOKEN" ]; then | |
| echo "present=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "present=false" >> "$GITHUB_OUTPUT" | |
| echo "EXPO_PREVIEW_TOKEN is not available; skipping the iOS preview." | |
| fi | |
| - name: Checkout | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | |
| with: | |
| fetch-depth: 0 | |
| # The steps below run dependency and build scripts; they get no token. | |
| - name: Drop checkout credentials | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: ./.github/actions/drop-checkout-credentials | |
| - name: Setup Vite+ | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 | |
| with: | |
| node-version-file: package.json | |
| cache: true | |
| run-install: | | |
| args: | |
| - --filter=@t3tools/mobile... | |
| - name: Expose pnpm | |
| if: steps.expo-token.outputs.present == 'true' | |
| run: | | |
| pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")" | |
| vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin" | |
| echo "$vp_pnpm_bin" >> "$GITHUB_PATH" | |
| "$vp_pnpm_bin/pnpm" --version | |
| - name: Setup EAS | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1 | |
| with: | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_PREVIEW_TOKEN }} | |
| packager: npm | |
| - name: Pull preview environment variables | |
| if: steps.expo-token.outputs.present == 'true' | |
| working-directory: apps/mobile | |
| run: | | |
| eas env:pull preview --non-interactive | |
| node --input-type=module <<'NODE' | |
| import { appendFileSync, readFileSync } from "node:fs"; | |
| import { parseEnv } from "node:util"; | |
| const env = parseEnv(readFileSync(".env.local", "utf8")); | |
| const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE; | |
| if (googleServicesFile) { | |
| appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`); | |
| } | |
| NODE | |
| # The same command the Expo action runs, so this is the runtime version the update gets. | |
| - id: client | |
| name: Find the client for this fingerprint | |
| if: steps.expo-token.outputs.present == 'true' | |
| working-directory: apps/mobile | |
| shell: bash | |
| run: | | |
| hash="$(eas env:exec --non-interactive preview "npx expo-updates fingerprint:generate --platform ios" | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')" | |
| echo "fingerprint=$hash" >> "$GITHUB_OUTPUT" | |
| tag="mobile-ios-preview-build/$hash" | |
| link="" | |
| if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then | |
| link="$(git tag -l --format='%(contents)' "$tag" | node "$GITHUB_WORKSPACE/.github/scripts/mobile-ios-preview-record.cjs" read)" | |
| fi | |
| if [ -z "$link" ]; then | |
| # A client EAS built before this job existed; expired ones are gone. | |
| link="$(eas build:list --platform ios --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \ | |
| | sed -n '/^\[/,$p' \ | |
| | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '[.[] | select((.expirationDate // "9999") > $now)][0] | select(. != null) | "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/\(.id)"')" | |
| fi | |
| echo "link=$link" >> "$GITHUB_OUTPUT" | |
| if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi | |
| echo "ios fingerprint \`$hash\`: ${link:-no client yet, building on Blacksmith}" >> "$GITHUB_STEP_SUMMARY" | |
| - id: update | |
| name: Publish the update | |
| if: steps.expo-token.outputs.present == 'true' | |
| working-directory: apps/mobile | |
| shell: bash | |
| run: | | |
| group="$(eas update --auto --branch "pr-$PR" --platform ios --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')" | |
| echo "group=$group" >> "$GITHUB_OUTPUT" | |
| # Preview build tags store the install link for each fingerprint; older EAS clients also count. | |
| android: | |
| name: EAS Preview (Android) | |
| if: | | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment') && | |
| (github.event.action != 'labeled' || github.event.label.name == '🚀 Mobile Continuous Deployment') | |
| runs-on: blacksmith-8vcpu-ubuntu-2404 | |
| concurrency: | |
| group: mobile-eas-preview-android-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| outputs: | |
| group: ${{ steps.update.outputs.group }} | |
| client: ${{ steps.client.outputs.link }} | |
| build: ${{ steps.client.outputs.build }} | |
| fingerprint: ${{ steps.client.outputs.fingerprint }} | |
| env: | |
| APP_VARIANT: preview | |
| NODE_OPTIONS: --max-old-space-size=8192 | |
| MOBILE_VERSION_POLICY: fingerprint | |
| EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }} | |
| GH_TOKEN: ${{ github.token }} | |
| PR: ${{ github.event.pull_request.number }} | |
| steps: | |
| - id: expo-token | |
| name: Check for EXPO_PREVIEW_TOKEN | |
| run: | | |
| if [ -n "$EXPO_TOKEN" ]; then | |
| echo "present=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "present=false" >> "$GITHUB_OUTPUT" | |
| echo "EXPO_PREVIEW_TOKEN is not available; skipping the Android preview." | |
| fi | |
| - name: Checkout | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | |
| with: | |
| fetch-depth: 0 | |
| # The steps below run dependency and build scripts; they get no token. | |
| - name: Drop checkout credentials | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: ./.github/actions/drop-checkout-credentials | |
| - name: Setup Vite+ | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 | |
| with: | |
| node-version-file: package.json | |
| cache: true | |
| run-install: | | |
| args: | |
| - --filter=@t3tools/mobile... | |
| - name: Expose pnpm | |
| if: steps.expo-token.outputs.present == 'true' | |
| run: | | |
| pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")" | |
| vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin" | |
| echo "$vp_pnpm_bin" >> "$GITHUB_PATH" | |
| "$vp_pnpm_bin/pnpm" --version | |
| - name: Setup EAS | |
| if: steps.expo-token.outputs.present == 'true' | |
| uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1 | |
| with: | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_PREVIEW_TOKEN }} | |
| packager: npm | |
| - name: Pull preview environment variables | |
| if: steps.expo-token.outputs.present == 'true' | |
| working-directory: apps/mobile | |
| run: | | |
| eas env:pull preview --non-interactive | |
| node --input-type=module <<'NODE' | |
| import { appendFileSync, readFileSync } from "node:fs"; | |
| import { parseEnv } from "node:util"; | |
| const env = parseEnv(readFileSync(".env.local", "utf8")); | |
| const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE; | |
| if (googleServicesFile) { | |
| appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`); | |
| } | |
| NODE | |
| # The same command the Expo action runs, so this is the runtime version the update gets. | |
| - id: client | |
| name: Find the client for this fingerprint | |
| if: steps.expo-token.outputs.present == 'true' | |
| working-directory: apps/mobile | |
| shell: bash | |
| run: | | |
| hash="$(eas env:exec --non-interactive preview "npx expo-updates fingerprint:generate --platform android" | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')" | |
| echo "fingerprint=$hash" >> "$GITHUB_OUTPUT" | |
| tag="mobile-android-preview-build/$hash" | |
| link="" | |
| if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then | |
| link="$(git tag -l --format='%(contents:subject)' "$tag")" | |
| else | |
| # A client EAS built before this job existed; expired ones are gone. | |
| link="$(eas build:list --platform android --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \ | |
| | sed -n '/^\[/,$p' \ | |
| | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '[.[] | select((.expirationDate // "9999") > $now)][0] | select(. != null) | "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/\(.id)"')" | |
| fi | |
| echo "link=$link" >> "$GITHUB_OUTPUT" | |
| if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi | |
| echo "android fingerprint \`$hash\`: ${link:-no client yet, building on Blacksmith}" >> "$GITHUB_STEP_SUMMARY" | |
| - id: update | |
| name: Publish the update | |
| if: steps.expo-token.outputs.present == 'true' | |
| working-directory: apps/mobile | |
| shell: bash | |
| run: | | |
| group="$(eas update --auto --branch "pr-$PR" --platform android --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')" | |
| echo "group=$group" >> "$GITHUB_OUTPUT" | |
| # Each build runs in mobile-eas-preview-build.yml, whose record job alone gets | |
| # the token that pushes the tag. The group covers both of its jobs. | |
| android-build: | |
| name: Android preview client | |
| needs: android | |
| if: needs.android.outputs.build == 'true' | |
| concurrency: | |
| # One build per fingerprint; a second PR with the same one finds the tag. | |
| group: mobile-android-preview-build-${{ needs.android.outputs.fingerprint }} | |
| cancel-in-progress: false | |
| queue: max | |
| permissions: | |
| contents: write # the record job pushes the build record tag | |
| uses: ./.github/workflows/mobile-eas-preview-build.yml | |
| with: | |
| platform: android | |
| fingerprint: ${{ needs.android.outputs.fingerprint }} | |
| secrets: | |
| EXPO_PREVIEW_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }} | |
| ios-build: | |
| name: iOS preview client | |
| needs: ios | |
| if: needs.ios.outputs.build == 'true' | |
| concurrency: | |
| # One build per fingerprint; a second PR with the same one finds the tag. | |
| group: mobile-ios-preview-build-${{ needs.ios.outputs.fingerprint }} | |
| cancel-in-progress: false | |
| queue: max | |
| permissions: | |
| contents: write # the record job pushes the build record tag | |
| uses: ./.github/workflows/mobile-eas-preview-build.yml | |
| with: | |
| platform: ios | |
| fingerprint: ${{ needs.ios.outputs.fingerprint }} | |
| secrets: | |
| EXPO_PREVIEW_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }} | |
| comment: | |
| name: Mobile preview comment | |
| needs: [android, ios, android-build, ios-build] | |
| if: always() && !cancelled() && (needs.android.result == 'success' || needs.ios.result == 'success') | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| concurrency: | |
| group: mobile-preview-comment-${{ github.event.pull_request.number }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout comment script | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | |
| with: | |
| sparse-checkout: .github/scripts | |
| - name: Comment | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR: ${{ github.event.pull_request.number }} | |
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| ANDROID_FINGERPRINT: ${{ needs.android.outputs.fingerprint }} | |
| ANDROID_GROUP: ${{ needs.android.outputs.group }} | |
| ANDROID_CLIENT: ${{ needs.android-build.outputs.client || needs.android.outputs.client }} | |
| IOS_FINGERPRINT: ${{ needs.ios.outputs.fingerprint }} | |
| IOS_GROUP: ${{ needs.ios.outputs.group }} | |
| IOS_CLIENT: ${{ needs.ios-build.outputs.client || needs.ios.outputs.client }} | |
| run: node .github/scripts/mobile-preview-comment.cjs |