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 and submit it (TestFlight + Play internal
12# 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 until that version is released. After App
16# Store approval, Apple closes the release train and `version` must be
17# bumped before another iOS build can be submitted. Releasing to the App
18# Store stays a manual App Store Connect step.
19# 2. OTA: publish a production-channel update for each platform where at
20# least one finished production build matches the current native
21# fingerprint. Old-version binaries with a matching fingerprint receive
22# it too. When native drift means no binary could install the update,
23# it is skipped and flagged in the job summary instead of published
24# into the void.
25# workflow_dispatch remains as a manual override for both modes (e.g. to
26# retry an errored build or force an OTA).
27# Manual v2-preview builds keep the production app identity and disable OTA.
28# They auto-submit to TestFlight and the Google Play closed testing track v2.
29# Select the v2 branch when dispatching a preview build.
30on:
31 workflow_dispatch:
32 inputs:
33 mode:
34 description: "build (+ auto-submit to TestFlight / Google Play) or update (OTA)"
35 required: true
36 type: choice
37 default: build
38 options:
39 - build
40 - update
41 profile:
42 description: "Store build profile (v2-preview: TestFlight + Play closed track v2; build only)"
43 required: true
44 type: choice
45 default: production
46 options:
47 - production
48 - v2-preview
49 platform:
50 description: "Target platform"
51 required: true
52 type: choice
53 default: all
54 options:
55 - ios
56 - android
57 - all
58 version:
59 description: "Optional build version override (blank uses app.config.ts; an override is committed before building)"
60 required: false
61 type: string
62 message:
63 description: "OTA update message (mode=update only)"
64 required: false
65 type: string
66 push:
67 branches: [main]
68 paths:
69 - apps/mobile/**
70 - packages/client-runtime/**
71 - packages/contracts/**
72 - packages/shared/**
73 - assets/**
74 - scripts/**
75 - patches/**
76 - pnpm-lock.yaml
77 - pnpm-workspace.yaml
78 - .github/workflows/mobile-eas-production.yml
79
80# Serialize runs so OTAs publish in merge order. GitHub keeps at most one
81# queued run per group, so a burst of merges collapses into one run of the
82# newest commit — intermediate commits don't need their own OTA.
83concurrency:
84 group: mobile-eas-production
85 cancel-in-progress: false
86
87jobs:
88 production:
89 name: EAS ${{ inputs.profile || 'production' }} ${{ github.event_name == 'push' && 'auto' || inputs.mode }}
90 runs-on: blacksmith-8vcpu-ubuntu-2404
91 permissions:
92 contents: read
93 env:
94 APP_VARIANT: production
95 NODE_OPTIONS: --max-old-space-size=8192
96 steps:
97 - name: Reject preview OTA updates
98 if: github.event_name == 'workflow_dispatch' && inputs.profile == 'v2-preview' && inputs.mode == 'update'
99 run: |
100 echo "::error::V2 previews use store builds only. Select mode=build."
101 exit 1
102
103 - id: expo-token
104 name: Check for EXPO_TOKEN
105 env:
106 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
107 run: |
108 if [ -n "$EXPO_TOKEN" ]; then
109 echo "present=true" >> "$GITHUB_OUTPUT"
110 else
111 echo "present=false" >> "$GITHUB_OUTPUT"
112 echo "EXPO_TOKEN is not available; skipping EAS production job."
113 fi
114
115 - id: version_app_token
116 name: Mint release app token for version override
117 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.version != ''
118 uses: actions/create-github-app-token@v2
119 with:
120 app-id: ${{ secrets.RELEASE_APP_ID }}
121 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
122 owner: ${{ github.repository_owner }}
123
124 - name: Checkout
125 if: steps.expo-token.outputs.present == 'true'
126 uses: actions/checkout@v6
127 with:
128 fetch-depth: 0
129 token: ${{ steps.version_app_token.outputs.token || github.token }}
130 # No sparse-checkout here: it makes actions/checkout fetch with
131 # --filter=blob:none, and eas-cli archives the project via
132 # `git clone --depth 1 file://<workspace>`, which fails (exit 128)
133 # when the partial clone can't serve the unfetched blobs.
134
135 - name: Setup Vite+
136 if: steps.expo-token.outputs.present == 'true'
137 uses: voidzero-dev/setup-vp@v1
138 with:
139 node-version-file: package.json
140 cache: true
141 run-install: |
142 args:
143 - --filter=@t3tools/mobile...
144
145 - name: Verify v2 preview source
146 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.profile == 'v2-preview'
147 run: |
148 node --input-type=module -e '
149 import * as environment from "./packages/contracts/src/environment.ts";
150 if (environment.ORCHESTRATION_PROTOCOL_VERSION !== 2) {
151 throw new Error("V2 previews require a v2 source branch. Select the v2 branch when running this workflow.");
152 }
153 '
154
155 - name: Expose pnpm
156 if: steps.expo-token.outputs.present == 'true'
157 run: |
158 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
159 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
160 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
161 "$vp_pnpm_bin/pnpm" --version
162
163 - name: Setup EAS
164 if: steps.expo-token.outputs.present == 'true'
165 uses: expo/expo-github-action@v8
166 with:
167 eas-version: latest
168 token: ${{ secrets.EXPO_TOKEN }}
169 # npm, not pnpm: this only installs eas-cli into the action's own
170 # tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
171 # ignored build script (no allowBuilds config outside the repo).
172 packager: npm
173
174 - name: Pull production environment variables
175 if: steps.expo-token.outputs.present == 'true'
176 working-directory: apps/mobile
177 env:
178 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
179 run: eas env:pull production --non-interactive
180
181 - name: Apply manual version override
182 if: steps.version_app_token.outcome == 'success'
183 env:
184 GH_TOKEN: ${{ steps.version_app_token.outputs.token }}
185 APP_SLUG: ${{ steps.version_app_token.outputs.app-slug }}
186 RELEASE_VERSION: ${{ inputs.version }}
187 run: |
188 if [ "$GITHUB_REF_TYPE" != "branch" ]; then
189 echo "Version overrides require dispatching this workflow from a branch; received $GITHUB_REF_TYPE '$GITHUB_REF_NAME'." >&2
190 exit 1
191 fi
192 if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}$ ]]; then
193 echo "Version override must contain two or three dot-separated integers; received '$RELEASE_VERSION'." >&2
194 exit 1
195 fi
196
197 node --input-type=module -e '
198 import fs from "node:fs";
199 const path = "apps/mobile/app.config.ts";
200 const source = fs.readFileSync(path, "utf8");
201 const next = source.replace(
202 /^( version: ")[^"]+(".*)$/m,
203 `$1${process.env.RELEASE_VERSION}$2`,
204 );
205 if (next === source && !source.includes(` version: "${process.env.RELEASE_VERSION}"`)) {
206 throw new Error("Could not update app version");
207 }
208 fs.writeFileSync(path, next);
209 '
210 vp fmt apps/mobile/app.config.ts
211
212 if git diff --quiet -- apps/mobile/app.config.ts; then
213 echo "app.config.ts is already at $RELEASE_VERSION; no version commit needed."
214 exit 0
215 fi
216
217 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
218 git config user.name "${APP_SLUG}[bot]"
219 git config user.email "${user_id}+${APP_SLUG}[bot]@users.noreply.github.com"
220 git add apps/mobile/app.config.ts
221 git commit \
222 -m "chore(mobile): bump app version to $RELEASE_VERSION" \
223 -m "Co-authored-by: codex <codex@users.noreply.github.com>"
224 git push origin "HEAD:refs/heads/${GITHUB_REF_NAME}"
225
226 - name: Summarize manual build version
227 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
228 working-directory: apps/mobile
229 env:
230 MOBILE_BUILD_PROFILE: ${{ inputs.profile || 'production' }}
231 run: |
232 version="$(npx expo config --json --type public | jq -r '.version')"
233 {
234 echo "## Manual $MOBILE_BUILD_PROFILE build"
235 echo
236 echo "- App version: \`$version\`"
237 echo "- Platform: \`${{ inputs.platform }}\`"
238 echo
239 echo "> Apple closes an iOS release train after App Store approval. Before building iOS, confirm \`$version\` is newer than the approved App Store version."
240 } >> "$GITHUB_STEP_SUMMARY"
241
242 - name: Build and submit (manual)
243 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
244 working-directory: apps/mobile
245 env:
246 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
247 MOBILE_BUILD_PROFILE: ${{ inputs.profile || 'production' }}
248 run: eas build --platform ${{ inputs.platform }} --profile "$MOBILE_BUILD_PROFILE" --auto-submit --non-interactive --no-wait
249
250 - name: Publish OTA update (manual)
251 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'update'
252 working-directory: apps/mobile
253 env:
254 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
255 run: |
256 eas update \
257 --channel production \
258 --environment production \
259 --platform ${{ inputs.platform }} \
260 --message "${{ inputs.message || format('Production OTA ({0})', github.sha) }}" \
261 --non-interactive
262
263 # No --status filter on build:list: an in-queue/in-progress build must
264 # count as existing, or every merge during the build window would cut a
265 # duplicate. After an errored build, retry via workflow_dispatch
266 # mode=build — pushes won't re-trigger it until the app version changes.
267 - id: store_builds
268 name: Ensure store builds exist for the current app version
269 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
270 continue-on-error: true
271 working-directory: apps/mobile
272 env:
273 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
274 run: |
275 failed=0
276 version="$(npx expo config --json --type public | jq -r '.version')"
277 for platform in ios android; do
278 latest="$(eas build:list --platform "$platform" --build-profile production --limit 1 --json --non-interactive | jq -r '.[0].appVersion // "none"')"
279 if [ "$latest" = "$version" ]; then
280 echo "$platform: production build for $version already exists (or is in progress)"
281 continue
282 fi
283 echo "$platform: latest production build is $latest, app.config.ts says $version — building"
284 if eas build --platform "$platform" --profile production --auto-submit --non-interactive --no-wait; then
285 echo ":building_construction: $platform: scheduled production build and submission for $version" >> "$GITHUB_STEP_SUMMARY"
286 else
287 failed=1
288 echo ":x: $platform: production build or submission failed for $version" >> "$GITHUB_STEP_SUMMARY"
289 fi
290 done
291 exit "$failed"
292
293 - name: Publish fingerprint-gated OTA
294 if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
295 working-directory: apps/mobile
296 env:
297 EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
298 run: |
299 message="$(git log -1 --pretty=%s | head -c 120) ($(git rev-parse --short=9 HEAD))"
300 for platform in ios android; do
301 # eas-cli prints an environment-loaded notice to stdout before the
302 # JSON even with --json, so discard everything before the document.
303 hash="$(eas fingerprint:generate --platform "$platform" --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
304 matching="$(eas build:list --platform "$platform" --build-profile production --status finished --fingerprint-hash "$hash" --limit 1 --json --non-interactive | jq 'length')"
305 if [ "$matching" -gt 0 ]; then
306 eas update \
307 --channel production \
308 --environment production \
309 --platform "$platform" \
310 --message "$message" \
311 --non-interactive
312 echo ":white_check_mark: $platform: OTA published to production (fingerprint \`$hash\`)" >> "$GITHUB_STEP_SUMMARY"
313 else
314 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"
315 fi
316 done
317
318 - name: Propagate store build failure
319 if: steps.store_builds.outcome == 'failure'
320 run: exit 1