Open History to see the last commit
1name: Mobile EAS Production
2
3# Production builds and OTA updates run from CI (Linux) — never from a laptop.
4# Under the fingerprint runtime-version policy the fingerprint must be computed
5# in the same OS/pnpm as the EAS build; a macOS `eas build` computes a different
6# fingerprint (platform-specific deps + pnpm version) and errors. On this Linux
7# runner, with corepack pinning pnpm 10.24 in eas.json, local == build.
8#
9# Every merge to main that touches the mobile app reconciles, per platform:
10# 1. Store builds: if the latest production build's version differs from
11# app.config.ts, cut a new build with --auto-submit (TestFlight +
12# Play internal track). Bumping `version` is therefore all it takes to
13# start the next release train — the first build of a version enters
14# external-TestFlight beta review immediately, and later builds of the
15# same version auto-approve. Releasing to the App Store stays a manual
16# App Store Connect step.
17# 2. OTA: publish a production-channel update for each platform where at
18# least one finished production build matches the current native
19# fingerprint. Old-version binaries with a matching fingerprint receive
20# it too. When native drift means no binary could install the update,
21# it is skipped and flagged in the job summary instead of published
22# into the void.
23# workflow_dispatch remains as a manual override for both modes (e.g. to
24# retry an errored build or force an OTA).
25on:
26 workflow_dispatch:
27 inputs:
28 mode:
29 description: "build (+ auto-submit to TestFlight) or update (OTA)"
30 required: true
31 type: choice
32 default: build
33 options:
34 - build
35 - update
36 platform:
37 description: "Target platform"
38 required: true
39 type: choice
40 default: ios
41 options:
42 - ios
43 - android
44 - all
45 message:
46 description: "OTA update message (mode=update only)"
47 required: false
48 type: string
49 push:
50 branches: [main]
51 paths:
52 - apps/mobile/**
53 - packages/client-runtime/**
54 - packages/contracts/**
55 - packages/shared/**
56 - assets/**
57 - scripts/**
58 - patches/**
59 - pnpm-lock.yaml
60 - pnpm-workspace.yaml
61 - .github/workflows/mobile-eas-production.yml
62
63# Serialize runs so OTAs publish in merge order. GitHub keeps at most one
64# queued run per group, so a burst of merges collapses into one run of the
65# newest commit — intermediate commits don't need their own OTA.
66concurrency:
67 group: mobile-eas-production
68 cancel-in-progress: false
69
70jobs:
71 production:
72 name: EAS Production ${{ github.event_name == 'push' && 'auto' || inputs.mode }}
73 runs-on: blacksmith-8vcpu-ubuntu-2404
74 permissions:
75 contents: read
76 env:
77 APP_VARIANT: production
78 NODE_OPTIONS: --max-old-space-size=8192
79 steps:
80 - id: expo-token
81 name: Check for EXPO_TOKEN
82 env:
83 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
84 run: |
85 if [ -n "$EXPO_TOKEN" ]; then
86 echo "present=true" >> "$GITHUB_OUTPUT"
87 else
88 echo "present=false" >> "$GITHUB_OUTPUT"
89 echo "EXPO_TOKEN is not available; skipping EAS production job."
90 fi
91
92 - name: Checkout
93 if: steps.expo-token.outputs.present == 'true'
94 uses: actions/checkout@v6
95 with:
96 fetch-depth: 0
97 # No sparse-checkout here: it makes actions/checkout fetch with
98 # --filter=blob:none, and eas-cli archives the project via
99 # `git clone --depth 1 file://<workspace>`, which fails (exit 128)
100 # when the partial clone can't serve the unfetched blobs.
101
102 - name: Setup Vite+
103 if: steps.expo-token.outputs.present == 'true'
104 uses: voidzero-dev/setup-vp@v1
105 with:
106 node-version-file: package.json
107 cache: true
108 run-install: |
109 args:
110 - --filter=@t3tools/mobile...
111
112 - name: Expose pnpm
113 if: steps.expo-token.outputs.present == 'true'
114 run: |
115 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
116 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
117 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
118 "$vp_pnpm_bin/pnpm" --version
119
120 - name: Setup EAS
121 if: steps.expo-token.outputs.present == 'true'
122 uses: expo/expo-github-action@v8
123 with:
124 eas-version: latest
125 token: ${{ secrets.EXPO_TOKEN }}
126 # npm, not pnpm: this only installs eas-cli into the action's own
127 # tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
128 # ignored build script (no allowBuilds config outside the repo).
129 packager: npm
130
131 - name: Pull production environment variables
132 if: steps.expo-token.outputs.present == 'true'
133 working-directory: apps/mobile
134 env:
135 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
136 run: eas env:pull production --non-interactive
137
138 - name: Build and submit (manual)
139 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
140 working-directory: apps/mobile
141 env:
142 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
143 run: eas build --platform ${{ inputs.platform }} --profile production --auto-submit --non-interactive --no-wait
144
145 - name: Publish OTA update (manual)
146 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'update'
147 working-directory: apps/mobile
148 env:
149 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
150 run: |
151 eas update \
152 --channel production \
153 --environment production \
154 --platform ${{ inputs.platform }} \
155 --message "${{ inputs.message || format('Production OTA ({0})', github.sha) }}" \
156 --non-interactive
157
158 # No --status filter on build:list: an in-queue/in-progress build must
159 # count as existing, or every merge during the build window would cut a
160 # duplicate. Builds started here stay attached to this serialized run so
161 # the queued run for a later merge cannot overtake them and lose its OTA.
162 # After an errored build, retry via workflow_dispatch mode=build — pushes
163 # won't re-trigger it until the app version changes.
164 - id: store_builds
165 name: Ensure store builds exist for the current app version
166 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
167 continue-on-error: true
168 working-directory: apps/mobile
169 env:
170 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
171 run: |
172 failed=0
173 version="$(npx expo config --json --type public | jq -r '.version')"
174 for platform in ios android; do
175 latest="$(eas build:list --platform "$platform" --build-profile production --limit 1 --json --non-interactive | jq -r '.[0].appVersion // "none"')"
176 if [ "$latest" = "$version" ]; then
177 echo "$platform: production build for $version already exists (or is in progress)"
178 continue
179 fi
180 echo "$platform: latest production build is $latest, app.config.ts says $version — building"
181 if eas build --platform "$platform" --profile production --auto-submit --non-interactive; then
182 echo ":building_construction: $platform: cut production build for $version (auto-submitted)" >> "$GITHUB_STEP_SUMMARY"
183 else
184 failed=1
185 echo ":x: $platform: production build or submission failed for $version" >> "$GITHUB_STEP_SUMMARY"
186 fi
187 done
188 exit "$failed"
189
190 - name: Publish fingerprint-gated OTA
191 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
192 working-directory: apps/mobile
193 env:
194 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
195 run: |
196 message="$(git log -1 --pretty=%s | head -c 120) ($(git rev-parse --short=9 HEAD))"
197 for platform in ios android; do
198 # eas-cli prints an environment-loaded notice to stdout before the
199 # JSON even with --json, so discard everything before the document.
200 hash="$(eas fingerprint:generate --platform "$platform" --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
201 matching="$(eas build:list --platform "$platform" --build-profile production --status finished --fingerprint-hash "$hash" --limit 1 --json --non-interactive | jq 'length')"
202 if [ "$matching" -gt 0 ]; then
203 eas update \
204 --channel production \
205 --environment production \
206 --platform "$platform" \
207 --message "$message" \
208 --non-interactive
209 echo ":white_check_mark: $platform: OTA published to production (fingerprint \`$hash\`)" >> "$GITHUB_STEP_SUMMARY"
210 else
211 echo ":warning: $platform: no finished production build matches fingerprint \`$hash\` — OTA skipped; JS changes reach $platform only once a matching build ships" >> "$GITHUB_STEP_SUMMARY"
212 fi
213 done
214
215 - name: Propagate store build failure
216 if: steps.store_builds.outcome == 'failure'
217 run: exit 1