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