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