The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 09:45 UTC
ci(mobile): share one local build action across preview and store builds (#37755)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 16, 2026 at 12:30 UTC
c1a9279602db53bda109b5dd769ee8420b708b9a
6 files changed
+422
-734
.github/actions/drop-checkout-credentials/action.yml
new
+38
@@ -0,0 +1,38 @@
1
+name: Drop checkout credentials
2
+description: Removes the token actions/checkout leaves behind, so later steps can run dependency and build scripts.
3
+
4
+# checkout keeps the token in a file under RUNNER_TEMP that .git/config includes, so
5
+# both go. `persist-credentials: false` fails in this repo: its cleanup runs `git
6
+# submodule foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules).
7
+runs:
8
+ using: composite
9
+ steps:
10
+ - name: Drop checkout credentials
11
+ shell: bash
12
+ run: |
13
+ # Status 1 means no match; any other failure stops the step.
14
+ lookup() {
15
+ local status=0
16
+ git -C "$dir" config --local "$@" || status=$?
17
+ if [ "$status" -gt 1 ]; then exit "$status"; fi
18
+ }
19
+ for dir in . .trusted; do
20
+ [ -e "$dir/.git" ] || continue
21
+ lookup --get-regexp '^includeif\..*\.path$' | while read -r key file; do
22
+ rm -f "$file"
23
+ git -C "$dir" config --local --unset-all "$key"
24
+ done
25
+ lookup --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
26
+ git -C "$dir" config --local --unset-all "$key"
27
+ done
28
+ remaining="$(lookup --get-regexp 'extraheader|includeif')"
29
+ if [ -n "$remaining" ]; then
30
+ echo "::error::checkout credentials are still configured in $dir"
31
+ exit 1
32
+ fi
33
+ done
34
+ rm -f "$RUNNER_TEMP"/git-credentials-*.config
35
+ if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
36
+ echo "::error::a checkout credential file is still present"
37
+ exit 1
38
+ fi
.github/actions/eas-local-build/action.yml
new
+188
@@ -0,0 +1,188 @@
1
+name: EAS local build
2
+description: Installs the toolchain and mobile dependencies, then runs `eas build --local` on this runner.
3
+
4
+inputs:
5
+ platform:
6
+ description: android or ios
7
+ required: true
8
+ profile:
9
+ description: eas.json build profile
10
+ required: true
11
+ environment:
12
+ description: EAS environment to pull, preview or production
13
+ required: true
14
+ expo-token:
15
+ description: Expo token for that environment
16
+ required: true
17
+ output:
18
+ description: Path the build artifact is written to
19
+ required: true
20
+ cache:
21
+ description: "false for untrusted code: no sticky disk and no EAS cache, so nothing it writes reaches trusted builds"
22
+ default: "true"
23
+ sourcemaps-r2:
24
+ description: R2 credentials for the eas-build-on-success source map upload; EAS secrets don't reach local builds
25
+ default: ""
26
+
27
+runs:
28
+ using: composite
29
+ steps:
30
+ - name: Prepare Android build cache
31
+ if: inputs.platform == 'android' && inputs.cache == 'true'
32
+ shell: bash
33
+ env:
34
+ CACHE_NAME: ${{ inputs.environment == 'production' && 'store' || 'preview' }}
35
+ run: |
36
+ cache="$HOME/.cache/t3-android-$CACHE_NAME"
37
+ {
38
+ echo "GRADLE_USER_HOME=$cache/gradle"
39
+ echo "CCACHE_DIR=$cache/ccache"
40
+ echo "CCACHE_MAXSIZE=5G"
41
+ # Gradle installs the NDK fresh each run, so key on the compiler's version, not its mtime.
42
+ echo "CCACHE_COMPILERCHECK=%compiler% -v"
43
+ echo "pnpm_config_store_dir=$cache/pnpm-store"
44
+ # eas build --local copies the project here. A fixed path keeps
45
+ # ccache keys stable, and the same disk as the store lets pnpm hardlink.
46
+ echo "EAS_LOCAL_BUILD_WORKINGDIR=$cache/eas-build"
47
+ echo "CCACHE_BASEDIR=$cache/eas-build"
48
+ # CMake (3.17+) reads these, and AGP passes Gradle's environment through.
49
+ echo "CMAKE_C_COMPILER_LAUNCHER=ccache"
50
+ echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache"
51
+ } >> "$GITHUB_ENV"
52
+
53
+ - name: Mount Android build cache
54
+ if: inputs.platform == 'android' && inputs.cache == 'true'
55
+ uses: useblacksmith/stickydisk@3f6be1451e3cad893b778bc93495c80452a5da26 # v1.7.2
56
+ with:
57
+ key: ${{ github.repository }}-android-${{ inputs.environment == 'production' && 'store' || 'preview' }}-build
58
+ path: ~/.cache/t3-android-${{ inputs.environment == 'production' && 'store' || 'preview' }}
59
+
60
+ - name: Configure Gradle and ccache
61
+ if: inputs.platform == 'android' && inputs.cache == 'true'
62
+ shell: bash
63
+ run: |
64
+ mkdir -p "$GRADLE_USER_HOME" "$CCACHE_DIR"
65
+ rm -rf "$EAS_LOCAL_BUILD_WORKINGDIR"
66
+ # No daemon: nothing should hold the sticky disk open when it is committed.
67
+ printf 'org.gradle.caching=true\norg.gradle.daemon=false\n' > "$GRADLE_USER_HOME/gradle.properties"
68
+ sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
69
+ sudo apt-get update -qq && sudo apt-get install -y -qq ccache
70
+ ccache --zero-stats
71
+
72
+ # Matches the EAS build image in eas.json.
73
+ - name: Select Xcode 27.1
74
+ if: inputs.platform == 'ios'
75
+ shell: bash
76
+ run: |
77
+ xcode=/Applications/Xcode_27.1.app
78
+ if [ ! -d "$xcode" ]; then
79
+ ls -d /Applications/Xcode*.app
80
+ echo "::error::Xcode 27.1 is not on this runner."
81
+ exit 1
82
+ fi
83
+ sudo xcode-select -s "$xcode/Contents/Developer"
84
+ xcodebuild -version
85
+ echo "- Xcode: \`$(basename "$xcode")\`" >> "$GITHUB_STEP_SUMMARY"
86
+
87
+ # EAS's credentials step fails to import the distribution certificate without it.
88
+ - name: Install Apple WWDR G3 intermediate
89
+ if: inputs.platform == 'ios'
90
+ shell: bash
91
+ run: |
92
+ curl -fsSL -o "$RUNNER_TEMP/AppleWWDRCAG3.cer" https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
93
+ sudo security add-certificates -k /Library/Keychains/System.keychain "$RUNNER_TEMP/AppleWWDRCAG3.cer" || true
94
+ security find-certificate -c "Apple Worldwide Developer Relations" /Library/Keychains/System.keychain | grep labl
95
+
96
+ - name: Setup Node
97
+ uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
98
+ with:
99
+ node-version-file: package.json
100
+
101
+ - name: Enable corepack
102
+ shell: bash
103
+ run: |
104
+ npm install --global corepack@latest
105
+ corepack enable
106
+ pnpm --version
107
+
108
+ # EAS commands load app.config.ts, whose plugins must resolve. Keep install
109
+ # scripts: some download native assets that the build's fingerprint check hashes.
110
+ - name: Install mobile dependencies
111
+ shell: bash
112
+ run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile...
113
+
114
+ - name: Setup Java
115
+ if: inputs.platform == 'android'
116
+ uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
117
+ with:
118
+ distribution: temurin
119
+ java-version: 17
120
+
121
+ - name: Setup EAS
122
+ uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
123
+ with:
124
+ eas-version: latest
125
+ eas-cache: ${{ inputs.cache }}
126
+ token: ${{ inputs.expo-token }}
127
+ # npm, not pnpm: this only installs eas-cli into the action's own
128
+ # tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
129
+ # ignored build script (no allowBuilds config outside the repo).
130
+ packager: npm
131
+
132
+ - name: Build tools
133
+ if: inputs.platform == 'ios'
134
+ shell: bash
135
+ run: |
136
+ command -v pod || sudo gem install cocoapods --no-document
137
+ command -v fastlane || brew install fastlane
138
+ pod --version
139
+ fastlane --version | tail -1
140
+
141
+ # EAS commands skip dotenv, and the Android fingerprint hashes this file.
142
+ - name: Pull ${{ inputs.environment }} environment variables
143
+ shell: bash
144
+ working-directory: apps/mobile
145
+ env:
146
+ EXPO_TOKEN: ${{ inputs.expo-token }}
147
+ ENVIRONMENT: ${{ inputs.environment }}
148
+ PLATFORM: ${{ inputs.platform }}
149
+ run: |
150
+ eas env:pull "$ENVIRONMENT" --non-interactive
151
+ node --input-type=module <<'NODE'
152
+ import { appendFileSync, readFileSync } from "node:fs";
153
+ import { parseEnv } from "node:util";
154
+ const env = parseEnv(readFileSync(".env.local", "utf8"));
155
+ const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
156
+ if (!googleServicesFile && process.env.PLATFORM === "android") {
157
+ throw new Error(`T3CODE_ANDROID_GOOGLE_SERVICES_FILE is missing from the ${process.env.ENVIRONMENT} environment`);
158
+ }
159
+ if (googleServicesFile) {
160
+ appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
161
+ }
162
+ NODE
163
+
164
+ - name: Build
165
+ shell: bash
166
+ working-directory: apps/mobile
167
+ env:
168
+ EXPO_TOKEN: ${{ inputs.expo-token }}
169
+ MOBILE_SOURCEMAPS_R2: ${{ inputs.sourcemaps-r2 }}
170
+ PLATFORM: ${{ inputs.platform }}
171
+ PROFILE: ${{ inputs.profile }}
172
+ OUTPUT: ${{ inputs.output }}
173
+ run: |
174
+ if [ "$PLATFORM" = "ios" ]; then
175
+ # A real path: /var -> /private/var symlinks break the expo-widgets bundle step.
176
+ export EAS_LOCAL_BUILD_WORKINGDIR="$RUNNER_TEMP/eas-build"
177
+ fi
178
+ eas build --local --platform "$PLATFORM" --profile "$PROFILE" --non-interactive --output "$OUTPUT"
179
+
180
+ - name: Report ccache
181
+ if: inputs.platform == 'android' && inputs.cache == 'true'
182
+ shell: bash
183
+ run: |
184
+ {
185
+ echo '```'
186
+ ccache --show-stats
187
+ echo '```'
188
+ } >> "$GITHUB_STEP_SUMMARY"
.github/actions/record-build-tag/action.yml
new
+57
@@ -0,0 +1,57 @@
1
+name: Record build tag
2
+description: Pushes the tag that tells later runs a build for this fingerprint exists.
3
+
4
+inputs:
5
+ tag:
6
+ description: Tag name, without refs/tags/
7
+ required: true
8
+ message:
9
+ description: Annotated tag message; empty makes a lightweight tag
10
+ default: ""
11
+ replace:
12
+ description: "true replaces an existing tag; otherwise an existing tag counts as recorded"
13
+ default: "false"
14
+ token:
15
+ description: Token with contents write
16
+ required: true
17
+
18
+runs:
19
+ using: composite
20
+ steps:
21
+ - name: Record build tag
22
+ shell: bash
23
+ env:
24
+ TAG: ${{ inputs.tag }}
25
+ MESSAGE: ${{ inputs.message }}
26
+ REPLACE: ${{ inputs.replace }}
27
+ GH_TOKEN: ${{ inputs.token }}
28
+ run: |
29
+ git config user.name "github-actions[bot]"
30
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
31
+ remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
32
+ # GitHub occasionally fails ref writes server-side ("fatal error in commit_refs").
33
+ for attempt in 1 2 3; do
34
+ if refs="$(git ls-remote "$remote" "refs/tags/$TAG")"; then
35
+ old="$(printf '%s\n' "$refs" | while read -r sha ref; do
36
+ if [ "$ref" = "refs/tags/$TAG" ]; then echo "$sha"; fi
37
+ done)"
38
+ if [ -n "$old" ] && [ "$REPLACE" != "true" ]; then
39
+ echo "$TAG exists."
40
+ exit 0
41
+ fi
42
+ if [ -n "$MESSAGE" ]; then
43
+ git tag -f -a "$TAG" -m "$MESSAGE"
44
+ else
45
+ git tag -f "$TAG"
46
+ fi
47
+ # An empty lease means the tag must not exist yet.
48
+ if git push --force-with-lease="refs/tags/$TAG:$old" "$remote" "refs/tags/$TAG"; then
49
+ exit 0
50
+ fi
51
+ fi
52
+ if [ "$attempt" = 3 ]; then
53
+ echo "::error::Could not push $TAG."
54
+ exit 1
55
+ fi
56
+ sleep $((attempt * 15))
57
+ done
.github/workflows/mobile-eas-preview-fork.yml
+38
-187
@@ -87,40 +87,20 @@ jobs:
87
fetch-depth: 0
88
# No sparse-checkout: see mobile-eas-preview.yml.
89
90
- # The comment script comes from main, not from the PR.
90
+ # Scripts and actions come from main, not from the PR.
91
- name: Checkout trusted scripts
92
if: steps.expo-token.outputs.present == 'true'
93
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
94
with:
95
path: .trusted
96
- sparse-checkout: .github/scripts
96
+ sparse-checkout: |
97
+ .github/scripts
98
+ .github/actions
99
98
- # The steps below run the PR's dependency and build scripts; they get no token.
99
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
100
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
101
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
100
+ # The steps below run dependency and build scripts; they get no token.
101
- name: Drop checkout credentials
102
if: steps.expo-token.outputs.present == 'true'
104
- run: |
105
- for dir in . .trusted; do
106
- [ -e "$dir/.git" ] || continue
107
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
108
- rm -f "$file"
109
- git -C "$dir" config --local --unset-all "$key"
110
- done
111
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
112
- git -C "$dir" config --local --unset-all "$key"
113
- done
114
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
115
- echo "::error::checkout credentials are still configured in $dir"
116
- exit 1
117
- fi
118
- done
119
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
120
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
121
- echo "::error::a checkout credential file is still present"
122
- exit 1
123
- fi
103
+ uses: ./.trusted/.github/actions/drop-checkout-credentials
104
105
# No caches: pull_request_target saves them under main's scope, where
106
# trusted workflows with other secrets would restore what PR code wrote.
@@ -268,91 +248,37 @@ jobs:
248
ref: ${{ github.event.pull_request.head.sha }}
249
fetch-depth: 0
250
271
- # The comment script comes from main, not from the PR.
251
+ # Scripts and actions come from main, not from the PR.
252
- name: Checkout trusted scripts
253
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
254
with:
255
path: .trusted
276
- sparse-checkout: .github/scripts
256
+ sparse-checkout: |
257
+ .github/scripts
258
+ .github/actions
259
278
- # The steps below run the PR's dependency and build scripts; they get no token.
279
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
280
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
281
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
260
+ # The steps below run dependency and build scripts; they get no token.
261
- name: Drop checkout credentials
283
- run: |
284
- for dir in . .trusted; do
285
- [ -e "$dir/.git" ] || continue
286
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
287
- rm -f "$file"
288
- git -C "$dir" config --local --unset-all "$key"
289
- done
290
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
291
- git -C "$dir" config --local --unset-all "$key"
292
- done
293
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
294
- echo "::error::checkout credentials are still configured in $dir"
295
- exit 1
296
- fi
297
- done
298
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
299
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
300
- echo "::error::a checkout credential file is still present"
301
- exit 1
302
- fi
303
-
304
- - name: Setup Node
305
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
306
- with:
307
- node-version-file: package.json
308
-
309
- - name: Enable corepack
310
- run: |
311
- npm install --global corepack@latest
312
- corepack enable
313
- pnpm --version
262
+ uses: ./.trusted/.github/actions/drop-checkout-credentials
263
315
- - name: Install mobile dependencies
316
- run: pnpm install --frozen-lockfile --filter=@t3tools/mobile...
317
-
318
- - name: Setup Java
319
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
264
+ # Cold: no sticky disk or EAS cache that trusted builds would restore.
265
+ - name: Build
266
+ uses: ./.trusted/.github/actions/eas-local-build
267
with:
321
- distribution: temurin
322
- java-version: 17
323
-
324
- - name: Setup EAS
325
- uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
326
- with:
327
- eas-version: latest
328
- eas-cache: false
329
- token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
330
- packager: npm
331
-
332
- - name: Pull preview environment variables
333
- working-directory: apps/mobile
334
- env:
335
- EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
336
- run: |
337
- eas env:pull preview --non-interactive
338
- node --input-type=module <<'NODE'
339
- import { appendFileSync, readFileSync } from "node:fs";
340
- import { parseEnv } from "node:util";
341
- const env = parseEnv(readFileSync(".env.local", "utf8"));
342
- const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
343
- if (googleServicesFile) {
344
- appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
345
- }
346
- NODE
268
+ platform: android
269
+ profile: preview:dev
270
+ environment: preview
271
+ expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
272
+ output: ${{ runner.temp }}/t3code-preview.apk
273
+ cache: "false"
274
275
- id: build
349
- name: Build and upload
276
+ name: Upload
277
working-directory: apps/mobile
278
shell: bash
279
env:
280
EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
281
run: |
355
- eas build --local --platform android --profile preview:dev --non-interactive --output "$RUNNER_TEMP/t3code-preview.apk"
282
eas upload --platform android --build-path "$RUNNER_TEMP/t3code-preview.apk" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
283
link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
284
if [ -z "$link" ]; then
@@ -384,112 +310,37 @@ jobs:
310
ref: ${{ github.event.pull_request.head.sha }}
311
fetch-depth: 0
312
387
- # The comment script comes from main, not from the PR.
313
+ # Scripts and actions come from main, not from the PR.
314
- name: Checkout trusted scripts
315
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
316
with:
317
path: .trusted
392
- sparse-checkout: .github/scripts
318
+ sparse-checkout: |
319
+ .github/scripts
320
+ .github/actions
321
394
- # The steps below run the PR's dependency and build scripts; they get no token.
395
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
396
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
397
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
322
+ # The steps below run dependency and build scripts; they get no token.
323
- name: Drop checkout credentials
399
- run: |
400
- for dir in . .trusted; do
401
- [ -e "$dir/.git" ] || continue
402
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
403
- rm -f "$file"
404
- git -C "$dir" config --local --unset-all "$key"
405
- done
406
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
407
- git -C "$dir" config --local --unset-all "$key"
408
- done
409
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
410
- echo "::error::checkout credentials are still configured in $dir"
411
- exit 1
412
- fi
413
- done
414
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
415
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
416
- echo "::error::a checkout credential file is still present"
417
- exit 1
418
- fi
419
-
420
- - name: Select Xcode 27.1
421
- run: |
422
- xcode=/Applications/Xcode_27.1.app
423
- if [ ! -d "$xcode" ]; then
424
- ls -d /Applications/Xcode*.app
425
- echo "::error::Xcode 27.1 is not on this runner."
426
- exit 1
427
- fi
428
- sudo xcode-select -s "$xcode/Contents/Developer"
429
- xcodebuild -version
430
- echo "- Xcode: \`$(basename "$xcode")\`" >> "$GITHUB_STEP_SUMMARY"
431
-
432
- # EAS's credentials step fails to import the distribution certificate without it.
433
- - name: Install Apple WWDR G3 intermediate
434
- run: |
435
- curl -fsSL -o "$RUNNER_TEMP/AppleWWDRCAG3.cer" https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
436
- sudo security add-certificates -k /Library/Keychains/System.keychain "$RUNNER_TEMP/AppleWWDRCAG3.cer" || true
437
- security find-certificate -c "Apple Worldwide Developer Relations" /Library/Keychains/System.keychain | grep -m1 labl
438
-
439
- - name: Setup Node
440
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
441
- with:
442
- node-version-file: package.json
443
-
444
- - name: Enable corepack
445
- run: |
446
- npm install --global corepack@latest
447
- corepack enable
448
- pnpm --version
449
-
450
- - name: Install mobile dependencies
451
- run: pnpm install --frozen-lockfile --filter=@t3tools/mobile...
324
+ uses: ./.trusted/.github/actions/drop-checkout-credentials
325
453
- - name: Setup EAS
454
- uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
326
+ # Cold: no sticky disk or EAS cache that trusted builds would restore.
327
+ - name: Build
328
+ uses: ./.trusted/.github/actions/eas-local-build
329
with:
456
- eas-version: latest
457
- eas-cache: false
458
- token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
459
- packager: npm
460
-
461
- - name: Build tools
462
- run: |
463
- command -v pod || sudo gem install cocoapods --no-document
464
- command -v fastlane || brew install fastlane
465
- pod --version
466
- fastlane --version | tail -1
467
-
468
- - name: Pull preview environment variables
469
- working-directory: apps/mobile
470
- env:
471
- EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
472
- run: |
473
- eas env:pull preview --non-interactive
474
- node --input-type=module <<'NODE'
475
- import { appendFileSync, readFileSync } from "node:fs";
476
- import { parseEnv } from "node:util";
477
- const env = parseEnv(readFileSync(".env.local", "utf8"));
478
- const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
479
- if (googleServicesFile) {
480
- appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
481
- }
482
- NODE
330
+ platform: ios
331
+ profile: preview:dev
332
+ environment: preview
333
+ expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
334
+ output: ${{ runner.temp }}/t3code-preview.ipa
335
+ cache: "false"
336
337
- id: build
485
- name: Build and upload
338
+ name: Upload
339
working-directory: apps/mobile
340
shell: bash
341
env:
342
EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
343
run: |
491
- export EAS_LOCAL_BUILD_WORKINGDIR="$RUNNER_TEMP/eas-build"
492
- eas build --local --platform ios --profile preview:dev --non-interactive --output "$RUNNER_TEMP/t3code-preview.ipa"
344
eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
345
link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
346
if [ -z "$link" ]; then
.github/workflows/mobile-eas-preview.yml
+44
-269
@@ -47,32 +47,10 @@ jobs:
47
with:
48
fetch-depth: 0
49
50
- # The steps below run the PR's dependency and build scripts; they get no token.
51
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
52
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
53
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
50
+ # The steps below run dependency and build scripts; they get no token.
51
- name: Drop checkout credentials
52
if: steps.expo-token.outputs.present == 'true'
56
- run: |
57
- for dir in . .trusted; do
58
- [ -e "$dir/.git" ] || continue
59
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
60
- rm -f "$file"
61
- git -C "$dir" config --local --unset-all "$key"
62
- done
63
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
64
- git -C "$dir" config --local --unset-all "$key"
65
- done
66
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
67
- echo "::error::checkout credentials are still configured in $dir"
68
- exit 1
69
- fi
70
- done
71
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
72
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
73
- echo "::error::a checkout credential file is still present"
74
- exit 1
75
- fi
53
+ uses: ./.github/actions/drop-checkout-credentials
54
55
- name: Setup Vite+
56
if: steps.expo-token.outputs.present == 'true'
@@ -191,32 +169,10 @@ jobs:
169
with:
170
fetch-depth: 0
171
194
- # The steps below run the PR's dependency and build scripts; they get no token.
195
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
196
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
197
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
172
+ # The steps below run dependency and build scripts; they get no token.
173
- name: Drop checkout credentials
174
if: steps.expo-token.outputs.present == 'true'
200
- run: |
201
- for dir in . .trusted; do
202
- [ -e "$dir/.git" ] || continue
203
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
204
- rm -f "$file"
205
- git -C "$dir" config --local --unset-all "$key"
206
- done
207
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
208
- git -C "$dir" config --local --unset-all "$key"
209
- done
210
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
211
- echo "::error::checkout credentials are still configured in $dir"
212
- exit 1
213
- fi
214
- done
215
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
216
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
217
- echo "::error::a checkout credential file is still present"
218
- exit 1
219
- fi
175
+ uses: ./.github/actions/drop-checkout-credentials
176
177
- name: Setup Vite+
178
if: steps.expo-token.outputs.present == 'true'
@@ -330,124 +286,27 @@ jobs:
286
echo "link=$(git tag -l --format='%(contents:subject)' "$BUILD_TAG")" >> "$GITHUB_OUTPUT"
287
fi
288
333
- # The steps below run the PR's dependency and build scripts; they get no token.
334
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
335
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
336
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
289
+ # The steps below run dependency and build scripts; they get no token.
290
- name: Drop checkout credentials
338
- run: |
339
- for dir in . .trusted; do
340
- [ -e "$dir/.git" ] || continue
341
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
342
- rm -f "$file"
343
- git -C "$dir" config --local --unset-all "$key"
344
- done
345
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
346
- git -C "$dir" config --local --unset-all "$key"
347
- done
348
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
349
- echo "::error::checkout credentials are still configured in $dir"
350
- exit 1
351
- fi
352
- done
353
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
354
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
355
- echo "::error::a checkout credential file is still present"
356
- exit 1
357
- fi
291
+ uses: ./.github/actions/drop-checkout-credentials
292
359
- - name: Prepare build directories
360
- if: steps.record.outputs.built != 'true'
361
- run: |
362
- cache="$HOME/.cache/t3-android-preview"
363
- {
364
- echo "GRADLE_USER_HOME=$cache/gradle"
365
- echo "CCACHE_DIR=$cache/ccache"
366
- echo "CCACHE_MAXSIZE=5G"
367
- # Gradle installs the NDK fresh each run, so key on the compiler's version, not its mtime.
368
- echo "CCACHE_COMPILERCHECK=%compiler% -v"
369
- echo "pnpm_config_store_dir=$cache/pnpm-store"
370
- # eas build --local copies the project here. A fixed path keeps
371
- # ccache keys stable, and the same disk as the store lets pnpm hardlink.
372
- echo "EAS_LOCAL_BUILD_WORKINGDIR=$cache/eas-build"
373
- echo "CCACHE_BASEDIR=$cache/eas-build"
374
- echo "CMAKE_C_COMPILER_LAUNCHER=ccache"
375
- echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache"
376
- } >> "$GITHUB_ENV"
377
-
378
- - name: Mount build cache
293
+ - name: Build
294
if: steps.record.outputs.built != 'true'
380
- uses: useblacksmith/stickydisk@3f6be1451e3cad893b778bc93495c80452a5da26 # v1.7.2
295
+ uses: ./.github/actions/eas-local-build
296
with:
382
- key: ${{ github.repository }}-android-preview-build
383
- path: ~/.cache/t3-android-preview
384
-
385
- - name: Configure Gradle and ccache
386
- if: steps.record.outputs.built != 'true'
387
- run: |
388
- mkdir -p "$GRADLE_USER_HOME" "$CCACHE_DIR"
389
- rm -rf "$EAS_LOCAL_BUILD_WORKINGDIR"
390
- # No daemon: nothing should hold the sticky disk open when it is committed.
391
- printf 'org.gradle.caching=true\norg.gradle.daemon=false\n' > "$GRADLE_USER_HOME/gradle.properties"
392
- sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
393
- sudo apt-get update -qq && sudo apt-get install -y -qq ccache
394
- ccache --zero-stats
395
-
396
- - name: Setup Node
397
- if: steps.record.outputs.built != 'true'
398
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
399
- with:
400
- node-version-file: package.json
401
-
402
- - name: Enable corepack
403
- if: steps.record.outputs.built != 'true'
404
- run: |
405
- npm install --global corepack@latest
406
- corepack enable
407
- pnpm --version
408
-
409
- - name: Install mobile dependencies
410
- if: steps.record.outputs.built != 'true'
411
- run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile...
412
-
413
- - name: Setup Java
414
- if: steps.record.outputs.built != 'true'
415
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
416
- with:
417
- distribution: temurin
418
- java-version: 17
419
-
420
- - name: Setup EAS
421
- if: steps.record.outputs.built != 'true'
422
- uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
423
- with:
424
- eas-version: latest
425
- token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
426
- packager: npm
427
-
428
- - name: Pull preview environment variables
429
- if: steps.record.outputs.built != 'true'
430
- working-directory: apps/mobile
431
- run: |
432
- eas env:pull preview --non-interactive
433
- node --input-type=module <<'NODE'
434
- import { appendFileSync, readFileSync } from "node:fs";
435
- import { parseEnv } from "node:util";
436
- const env = parseEnv(readFileSync(".env.local", "utf8"));
437
- const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
438
- if (googleServicesFile) {
439
- appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
440
- }
441
- NODE
297
+ platform: android
298
+ profile: preview:dev
299
+ environment: preview
300
+ expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
301
+ output: ${{ runner.temp }}/t3code-preview.apk
302
303
# `eas upload` hosts the APK on EAS and returns the page testers install from.
304
- id: build
445
- name: Build and upload
305
+ name: Upload
306
if: steps.record.outputs.built != 'true'
307
working-directory: apps/mobile
308
shell: bash
309
run: |
450
- eas build --local --platform android --profile preview:dev --non-interactive --output "$RUNNER_TEMP/t3code-preview.apk"
310
eas upload --platform android --build-path "$RUNNER_TEMP/t3code-preview.apk" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
311
link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
312
if [ -z "$link" ]; then
@@ -455,25 +314,16 @@ jobs:
314
exit 1
315
fi
316
echo "link=$link" >> "$GITHUB_OUTPUT"
458
- {
459
- echo "### Android preview client for \`$FINGERPRINT\`: $link"
460
- echo '```'
461
- ccache --show-stats
462
- echo '```'
463
- } >> "$GITHUB_STEP_SUMMARY"
317
+ echo "### Android preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
318
319
# The tag is the record later runs look up; its message is the install link.
320
- name: Record build
321
if: steps.record.outputs.built != 'true'
468
- env:
469
- LINK: ${{ steps.build.outputs.link }}
470
- GH_TOKEN: ${{ github.token }}
471
- run: |
472
- git config user.name "github-actions[bot]"
473
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
474
- git tag -a "$BUILD_TAG" -m "$LINK"
475
- # Only this step has the token; the checkout's copy was removed before the build.
476
- git push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "refs/tags/$BUILD_TAG"
322
+ uses: ./.github/actions/record-build-tag
323
+ with:
324
+ tag: ${{ env.BUILD_TAG }}
325
+ message: ${{ steps.build.outputs.link }}
326
+ token: ${{ github.token }}
327
328
ios-build:
329
name: iOS preview client
@@ -520,104 +370,27 @@ jobs:
370
fi
371
fi
372
523
- # The steps below run the PR's dependency and build scripts; they get no token.
524
- # checkout keeps it in a file under RUNNER_TEMP that .git/config includes, so both
525
- # go. Asking checkout not to persist it fails here: that cleanup runs `git submodule
526
- # foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules entry).
373
+ # The steps below run dependency and build scripts; they get no token.
374
- name: Drop checkout credentials
528
- run: |
529
- for dir in . .trusted; do
530
- [ -e "$dir/.git" ] || continue
531
- git -C "$dir" config --local --get-regexp '^includeif\..*\.path$' | while read -r key file; do
532
- rm -f "$file"
533
- git -C "$dir" config --local --unset-all "$key"
534
- done
535
- git -C "$dir" config --local --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
536
- git -C "$dir" config --local --unset-all "$key"
537
- done
538
- if git -C "$dir" config --local --get-regexp 'extraheader|includeif'; then
539
- echo "::error::checkout credentials are still configured in $dir"
540
- exit 1
541
- fi
542
- done
543
- rm -f "$RUNNER_TEMP"/git-credentials-*.config
544
- if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
545
- echo "::error::a checkout credential file is still present"
546
- exit 1
547
- fi
548
-
549
- - name: Select Xcode 27.1
550
- if: steps.record.outputs.built != 'true'
551
- run: |
552
- xcode=/Applications/Xcode_27.1.app
553
- if [ ! -d "$xcode" ]; then
554
- ls -d /Applications/Xcode*.app
555
- echo "::error::Xcode 27.1 is not on this runner."
556
- exit 1
557
- fi
558
- sudo xcode-select -s "$xcode/Contents/Developer"
559
- xcodebuild -version
560
- echo "- Xcode: \`$(basename "$xcode")\`" >> "$GITHUB_STEP_SUMMARY"
375
+ uses: ./.github/actions/drop-checkout-credentials
376
562
- # EAS's credentials step fails to import the distribution certificate without it.
563
- - name: Install Apple WWDR G3 intermediate
377
+ - name: Build
378
if: steps.record.outputs.built != 'true'
565
- run: |
566
- curl -fsSL -o "$RUNNER_TEMP/AppleWWDRCAG3.cer" https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
567
- sudo security add-certificates -k /Library/Keychains/System.keychain "$RUNNER_TEMP/AppleWWDRCAG3.cer" || true
568
- security find-certificate -c "Apple Worldwide Developer Relations" /Library/Keychains/System.keychain | grep -m1 labl
569
-
570
- - name: Enable corepack
571
- if: steps.record.outputs.built != 'true'
572
- run: |
573
- npm install --global corepack@latest
574
- corepack enable
575
- pnpm --version
576
-
577
- - name: Install mobile dependencies
578
- if: steps.record.outputs.built != 'true'
579
- run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile...
580
-
581
- - name: Setup EAS
582
- if: steps.record.outputs.built != 'true'
583
- uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
379
+ uses: ./.github/actions/eas-local-build
380
with:
585
- eas-version: latest
586
- token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
587
- packager: npm
588
-
589
- - name: Build tools
590
- if: steps.record.outputs.built != 'true'
591
- run: |
592
- command -v pod || sudo gem install cocoapods --no-document
593
- command -v fastlane || brew install fastlane
594
- pod --version
595
- fastlane --version | tail -1
596
-
597
- - name: Pull preview environment variables
598
- if: steps.record.outputs.built != 'true'
599
- working-directory: apps/mobile
600
- run: |
601
- eas env:pull preview --non-interactive
602
- node --input-type=module <<'NODE'
603
- import { appendFileSync, readFileSync } from "node:fs";
604
- import { parseEnv } from "node:util";
605
- const env = parseEnv(readFileSync(".env.local", "utf8"));
606
- const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
607
- if (googleServicesFile) {
608
- appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
609
- }
610
- NODE
381
+ platform: ios
382
+ profile: preview:dev
383
+ environment: preview
384
+ expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
385
+ output: ${{ runner.temp }}/t3code-preview.ipa
386
387
# EAS hosts the signed client and returns its install page.
388
- id: build
614
- name: Build and upload
389
+ name: Upload
390
if: steps.record.outputs.built != 'true'
391
working-directory: apps/mobile
392
shell: bash
393
run: |
619
- export EAS_LOCAL_BUILD_WORKINGDIR="$RUNNER_TEMP/eas-build"
620
- eas build --local --platform ios --profile preview:dev --non-interactive --output "$RUNNER_TEMP/t3code-preview.ipa"
394
eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
395
link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
396
if [ -z "$link" ]; then
@@ -625,28 +398,30 @@ jobs:
398
exit 1
399
fi
400
echo "link=$link" >> "$GITHUB_OUTPUT"
628
- {
629
- echo "### iOS preview client for \`$FINGERPRINT\`: $link"
630
- } >> "$GITHUB_STEP_SUMMARY"
401
+ echo "### iOS preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
402
403
# The tag stores the install link and provisioning-profile expiry.
633
- - name: Record build
404
+ - id: profile
405
+ name: Read the provisioning profile
406
if: steps.record.outputs.built != 'true'
407
env:
408
LINK: ${{ steps.build.outputs.link }}
637
- GH_TOKEN: ${{ github.token }}
409
run: |
639
- git config user.name "github-actions[bot]"
640
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
410
profile_path="$(unzip -Z -1 "$RUNNER_TEMP/t3code-preview.ipa" | grep -E '^Payload/[^/]+\.app/embedded\.mobileprovision$')"
642
- test -n "$profile_path"
411
unzip -p "$RUNNER_TEMP/t3code-preview.ipa" "$profile_path" > "$RUNNER_TEMP/preview.mobileprovision"
412
security cms -D -i "$RUNNER_TEMP/preview.mobileprovision" > "$RUNNER_TEMP/preview-profile.plist"
413
record="$(node .github/scripts/mobile-ios-preview-record.cjs create "$LINK" "$RUNNER_TEMP/preview-profile.plist")"
646
- old_tag="$(git rev-parse -q --verify "refs/tags/$BUILD_TAG" || true)"
647
- git tag -f -a "$BUILD_TAG" -m "$record"
648
- # Only this step has the token; the checkout's copy was removed before the build.
649
- git push --force-with-lease="refs/tags/$BUILD_TAG:$old_tag" "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "refs/tags/$BUILD_TAG"
414
+ echo "record=$record" >> "$GITHUB_OUTPUT"
415
+
416
+ # Replaces an expired record for the same fingerprint.
417
+ - name: Record build
418
+ if: steps.record.outputs.built != 'true'
419
+ uses: ./.github/actions/record-build-tag
420
+ with:
421
+ tag: ${{ env.BUILD_TAG }}
422
+ message: ${{ steps.profile.outputs.record }}
423
+ replace: "true"
424
+ token: ${{ github.token }}
425
426
comment:
427
name: Mobile preview comment
.github/workflows/mobile-eas-production.yml
+57
-278
@@ -7,10 +7,8 @@ name: Mobile EAS Production
7
# runner, with corepack pinning pnpm 10.24 in eas.json, local == build.
8
#
9
# Every merge reconciles native fingerprints and publishes matching OTAs.
10
-# Android store builds run here with `eas build --local` on Blacksmith (the
11
-# android job). iOS builds run on EAS unless the MOBILE_IOS_LOCAL_BUILDS
12
-# repository variable is `true`, which moves them to the ios job the same way.
13
-# Local builds never appear in `eas build:list`, so each finished local build
10
+# Store builds run here with `eas build --local` on Blacksmith (the android and
11
+# ios jobs). Local builds never appear in `eas build:list`, so each finished build
12
# pushes a mobile-android-build/<version>/<fingerprint> or
13
# mobile-ios-build/<profile>/<version>/<fingerprint> tag that the reconcile reads.
14
# iOS prereleases use the testflight profile (3.0.0); App Store binaries use
@@ -253,17 +251,9 @@ jobs:
251
echo "> Apple closes an iOS release train after App Store approval. Before building iOS, confirm \`$version\` is newer than the approved App Store version."
252
} >> "$GITHUB_STEP_SUMMARY"
253
256
- - name: Build and submit iOS (manual)
257
- if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.platform != 'android' && vars.MOBILE_IOS_LOCAL_BUILDS != 'true'
258
- working-directory: apps/mobile
259
- env:
260
- EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
261
- MOBILE_BUILD_PROFILE: ${{ inputs.profile || 'production' }}
262
- run: eas build --platform ios --profile "$MOBILE_BUILD_PROFILE" --auto-submit --non-interactive --no-wait
263
-
254
- id: ios_manual
255
name: Queue iOS build (manual)
266
- if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.platform != 'android' && vars.MOBILE_IOS_LOCAL_BUILDS == 'true'
256
+ if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.platform != 'android'
257
working-directory: apps/mobile
258
env:
259
EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
@@ -351,7 +341,6 @@ jobs:
341
working-directory: apps/mobile
342
env:
343
EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
354
- IOS_LOCAL_BUILDS: ${{ vars.MOBILE_IOS_LOCAL_BUILDS == 'true' }}
344
run: |
345
failed=0
346
message="$(git log -1 --pretty=%s | head -c 120) ($(git rev-parse --short=9 HEAD))"
@@ -374,19 +363,16 @@ jobs:
363
latest_version="$(eas build:list --platform "$platform" --build-profile "$profile" --limit 1 --json --non-interactive | jq -r '.[0].appVersion // "none"')"
364
# Local builds (the android and ios jobs) record each build as a tag;
365
# EAS records still count for builds made before that.
377
- tag_prefix=""
366
if [ "$platform" = "android" ]; then
367
tag_prefix="mobile-android-build"
380
- elif [ "$IOS_LOCAL_BUILDS" = "true" ]; then
368
+ else
369
tag_prefix="mobile-ios-build/$profile"
370
fi
383
- if [ -n "$tag_prefix" ]; then
384
- if [ -n "$(git tag -l "$tag_prefix/*/$hash")" ]; then
385
- finished=$((finished + 1))
386
- fi
387
- if [ -n "$(git tag -l "$tag_prefix/$version/*")" ]; then
388
- latest_version="$version"
389
- fi
371
+ if [ -n "$(git tag -l "$tag_prefix/*/$hash")" ]; then
372
+ finished=$((finished + 1))
373
+ fi
374
+ if [ -n "$(git tag -l "$tag_prefix/$version/*")" ]; then
375
+ latest_version="$version"
376
fi
377
378
if [ "$finished" -gt 0 ]; then
@@ -441,23 +427,14 @@ jobs:
427
echo ":building_construction: android: building and submitting $version in the Android store build job ($reason)" >> "$GITHUB_STEP_SUMMARY"
428
continue
429
fi
444
- if [ "$platform" = "ios" ] && [ "$IOS_LOCAL_BUILDS" = "true" ]; then
445
- {
446
- echo "ios_build=true"
447
- echo "ios_profile=$profile"
448
- echo "ios_fingerprint=$hash"
449
- echo "ios_version=$version"
450
- echo "ios_sha=$(git rev-parse HEAD)"
451
- } >> "$GITHUB_OUTPUT"
452
- echo ":building_construction: ios/$profile: building and submitting $version in the iOS store build job ($reason)" >> "$GITHUB_STEP_SUMMARY"
453
- continue
454
- fi
455
- if eas build --platform "$platform" --profile "$profile" --auto-submit --non-interactive --no-wait; then
456
- echo ":building_construction: $platform: scheduled production build and submission for $version ($reason)" >> "$GITHUB_STEP_SUMMARY"
457
- else
458
- failed=1
459
- echo ":x: $platform: production build or submission failed for $version" >> "$GITHUB_STEP_SUMMARY"
460
- fi
430
+ {
431
+ echo "ios_build=true"
432
+ echo "ios_profile=$profile"
433
+ echo "ios_fingerprint=$hash"
434
+ echo "ios_version=$version"
435
+ echo "ios_sha=$(git rev-parse HEAD)"
436
+ } >> "$GITHUB_OUTPUT"
437
+ echo ":building_construction: ios/$profile: building and submitting $version in the iOS store build job ($reason)" >> "$GITHUB_STEP_SUMMARY"
438
done
439
exit "$failed"
440
@@ -476,9 +453,9 @@ jobs:
453
fi
454
done
455
479
- # `eas build --local` on Blacksmith, ARM-only, without release lint (see the
480
- # production profile in eas.json), with Gradle, ccache, and pnpm state on a
481
- # sticky disk. Its own concurrency group keeps later OTAs from waiting on it.
456
+ # ARM-only, without release lint (see the production profile in eas.json),
457
+ # with Gradle, ccache, and pnpm state on a sticky disk. Its own concurrency
458
+ # group keeps later OTAs from waiting on it.
459
android:
460
name: Android store build
461
needs: production
@@ -503,20 +480,9 @@ jobs:
480
ref: ${{ needs.production.outputs.android_sha }}
481
fetch-depth: 0
482
506
- # Dependency scripts and the build run in this job; only Record build gets a token.
507
- # persist-credentials: false would clean up via `git submodule foreach`, which fails on .repos gitlinks.
483
+ # The steps below run dependency and build scripts; they get no token.
484
- name: Drop checkout credentials
509
- run: |
510
- git config --local --unset-all http.https://github.com/.extraheader || true
511
- { git config --local --name-only --get-regexp '^includeif\.' || true; } | while read -r key; do
512
- path=$(git config --local --get "$key")
513
- git config --local --unset-all "$key"
514
- case "$path" in "$RUNNER_TEMP"/*) rm -f "$path" ;; esac
515
- done
516
- if git config --local --get-regexp '^(http\..*\.extraheader|includeif\.)'; then
517
- echo "::error::Checkout credentials are still configured"
518
- exit 1
519
- fi
485
+ uses: ./.github/actions/drop-checkout-credentials
486
487
# A queued run can follow a build of the same fingerprint; manual runs always build.
488
- id: record
@@ -529,111 +495,22 @@ jobs:
495
echo ":white_check_mark: android: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY"
496
fi
497
532
- - name: Prepare build directories
533
- if: steps.record.outputs.built != 'true'
534
- run: |
535
- cache="$HOME/.cache/t3-android-store"
536
- {
537
- echo "GRADLE_USER_HOME=$cache/gradle"
538
- echo "CCACHE_DIR=$cache/ccache"
539
- echo "CCACHE_MAXSIZE=5G"
540
- # Gradle installs the NDK fresh each run, so key on the compiler's version, not its mtime.
541
- echo "CCACHE_COMPILERCHECK=%compiler% -v"
542
- echo "pnpm_config_store_dir=$cache/pnpm-store"
543
- # eas build --local copies the project here. A fixed path keeps
544
- # ccache keys stable, and the same disk as the store lets pnpm hardlink.
545
- echo "EAS_LOCAL_BUILD_WORKINGDIR=$cache/eas-build"
546
- echo "CCACHE_BASEDIR=$cache/eas-build"
547
- # CMake (3.17+) reads these, and AGP passes Gradle's environment through.
548
- echo "CMAKE_C_COMPILER_LAUNCHER=ccache"
549
- echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache"
550
- } >> "$GITHUB_ENV"
551
-
552
- - name: Mount build cache
553
- if: steps.record.outputs.built != 'true'
554
- uses: useblacksmith/stickydisk@3f6be1451e3cad893b778bc93495c80452a5da26 # v1.7.2
555
- with:
556
- key: ${{ github.repository }}-android-store-build
557
- path: ~/.cache/t3-android-store
558
-
559
- - name: Configure Gradle and ccache
560
- if: steps.record.outputs.built != 'true'
561
- run: |
562
- mkdir -p "$GRADLE_USER_HOME" "$CCACHE_DIR"
563
- rm -rf "$EAS_LOCAL_BUILD_WORKINGDIR"
564
- # No daemon: nothing should hold the sticky disk open when it is committed.
565
- printf 'org.gradle.caching=true\norg.gradle.daemon=false\n' > "$GRADLE_USER_HOME/gradle.properties"
566
- sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
567
- sudo apt-get update -qq && sudo apt-get install -y -qq ccache
568
- ccache --zero-stats
569
-
570
- - name: Setup Node
571
- if: steps.record.outputs.built != 'true'
572
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
573
- with:
574
- node-version-file: package.json
575
-
576
- - name: Enable corepack
577
- if: steps.record.outputs.built != 'true'
578
- run: |
579
- npm install --global corepack@latest
580
- corepack enable
581
- pnpm --version
582
-
583
- # EAS commands load app.config.ts, whose plugins must resolve. Keep install
584
- # scripts: some download native assets that the build's fingerprint check hashes.
585
- - name: Install mobile dependencies
586
- if: steps.record.outputs.built != 'true'
587
- run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile...
588
-
589
- - name: Setup Java
590
- if: steps.record.outputs.built != 'true'
591
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
592
- with:
593
- distribution: temurin
594
- java-version: 17
595
-
596
- - name: Setup EAS
498
+ - name: Build
499
if: steps.record.outputs.built != 'true'
598
- uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
500
+ uses: ./.github/actions/eas-local-build
501
with:
600
- eas-version: latest
601
- token: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
602
- packager: npm
603
-
604
- - name: Pull production environment variables
605
- if: steps.record.outputs.built != 'true'
606
- working-directory: apps/mobile
607
- run: |
608
- eas env:pull production --non-interactive
609
- node --input-type=module <<'NODE'
610
- import { appendFileSync, readFileSync } from "node:fs";
611
- import { parseEnv } from "node:util";
612
- const env = parseEnv(readFileSync(".env.local", "utf8"));
613
- const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
614
- if (!googleServicesFile) {
615
- throw new Error("T3CODE_ANDROID_GOOGLE_SERVICES_FILE is missing from the production environment");
616
- }
617
- appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
618
- NODE
619
-
620
- - name: Build
502
+ platform: android
503
+ profile: production
504
+ environment: production
505
+ expo-token: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
506
+ output: ${{ runner.temp }}/t3code.aab
507
+ sourcemaps-r2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }}
508
+
509
+ - name: Check ABIs
510
if: steps.record.outputs.built != 'true'
622
- working-directory: apps/mobile
623
- env:
624
- # EAS secret variables don't reach local builds; the eas-build-on-success
625
- # hook needs these to upload the bundle's source map.
626
- MOBILE_SOURCEMAPS_R2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }}
511
run: |
628
- eas build --local --platform android --profile production --non-interactive --output "$RUNNER_TEMP/t3code.aab"
512
abis="$(unzip -Z1 "$RUNNER_TEMP/t3code.aab" | sed -n 's|^base/lib/\([^/]*\)/.*|\1|p' | sort -u | paste -sd, -)"
630
- {
631
- echo "### Android $BUILD_TAG"
632
- echo "- ABIs: \`$abis\`"
633
- echo '```'
634
- ccache --show-stats
635
- echo '```'
636
- } >> "$GITHUB_STEP_SUMMARY"
513
+ echo "### Android $BUILD_TAG: \`$abis\`" >> "$GITHUB_STEP_SUMMARY"
514
if [ "$abis" != "arm64-v8a,armeabi-v7a" ]; then
515
echo "::error::Expected only ARM native libraries in the AAB, found $abis"
516
exit 1
@@ -658,30 +535,16 @@ jobs:
535
# pushed, the next merge rebuilds with a new build number; nothing is lost.
536
- name: Record build
537
if: steps.record.outputs.built != 'true'
661
- env:
662
- GH_TOKEN: ${{ github.token }}
538
+ uses: ./.github/actions/record-build-tag
539
+ with:
540
+ tag: ${{ env.BUILD_TAG }}
541
+ token: ${{ github.token }}
542
+
543
+ - name: Summarize
544
+ if: steps.record.outputs.built != 'true'
545
run: |
664
- sha="$(git rev-parse HEAD)"
665
- # GitHub occasionally fails ref writes server-side ("fatal error in commit_refs").
666
- for attempt in 1 2 3; do
667
- if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$BUILD_TAG" >/dev/null 2>&1; then
668
- echo "$BUILD_TAG exists."
669
- break
670
- fi
671
- if gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$BUILD_TAG" -f sha="$sha" >/dev/null; then
672
- break
673
- fi
674
- if [ "$attempt" = 3 ]; then
675
- echo "::error::Submitted, but could not create $BUILD_TAG; the next merge will rebuild."
676
- exit 1
677
- fi
678
- sleep $((attempt * 15))
679
- done
546
echo ":rocket: android: submitted and recorded \`$BUILD_TAG\`" >> "$GITHUB_STEP_SUMMARY"
547
682
- # Off unless the MOBILE_IOS_LOCAL_BUILDS repository variable is `true`; the
683
- # production job only sets ios_build then. Xcode 27.1 matches the EAS build
684
- # image in eas.json.
548
# No sticky disk: it mounts ext4 and only works on Linux runners.
549
ios:
550
name: iOS store build
@@ -708,20 +571,9 @@ jobs:
571
ref: ${{ needs.production.outputs.ios_sha }}
572
fetch-depth: 0
573
711
- # Dependency scripts and the build run in this job; only Record build gets a token.
712
- # persist-credentials: false would clean up via `git submodule foreach`, which fails on .repos gitlinks.
574
+ # The steps below run dependency and build scripts; they get no token.
575
- name: Drop checkout credentials
714
- run: |
715
- git config --local --unset-all http.https://github.com/.extraheader || true
716
- { git config --local --name-only --get-regexp '^includeif\.' || true; } | while read -r key; do
717
- path=$(git config --local --get "$key")
718
- git config --local --unset-all "$key"
719
- case "$path" in "$RUNNER_TEMP"/*) rm -f "$path" ;; esac
720
- done
721
- if git config --local --get-regexp '^(http\..*\.extraheader|includeif\.)'; then
722
- echo "::error::Checkout credentials are still configured"
723
- exit 1
724
- fi
576
+ uses: ./.github/actions/drop-checkout-credentials
577
578
# A queued run can follow a build of the same fingerprint; manual runs always build.
579
- id: record
@@ -734,78 +586,16 @@ jobs:
586
echo ":white_check_mark: ios: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY"
587
fi
588
737
- - name: Select Xcode 27.1
738
- if: steps.record.outputs.built != 'true'
739
- run: |
740
- xcode=/Applications/Xcode_27.1.app
741
- if [ ! -d "$xcode" ]; then
742
- ls -d /Applications/Xcode*.app
743
- echo "::error::Xcode 27.1 is not on this runner."
744
- exit 1
745
- fi
746
- sudo xcode-select -s "$xcode/Contents/Developer"
747
- xcodebuild -version
748
- echo "- Xcode: \`$(basename "$xcode")\`" >> "$GITHUB_STEP_SUMMARY"
749
-
750
- # EAS's credentials step fails to import the distribution certificate without it.
751
- - name: Install Apple WWDR G3 intermediate
752
- if: steps.record.outputs.built != 'true'
753
- run: |
754
- curl -fsSL -o "$RUNNER_TEMP/AppleWWDRCAG3.cer" https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
755
- sudo security add-certificates -k /Library/Keychains/System.keychain "$RUNNER_TEMP/AppleWWDRCAG3.cer" || true
756
- security find-certificate -c "Apple Worldwide Developer Relations" /Library/Keychains/System.keychain | grep -m1 labl
757
-
758
- - name: Setup Node
759
- if: steps.record.outputs.built != 'true'
760
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
761
- with:
762
- node-version-file: package.json
763
-
764
- - name: Enable corepack
765
- if: steps.record.outputs.built != 'true'
766
- run: |
767
- npm install --global corepack@latest
768
- corepack enable
769
- pnpm --version
770
-
771
- # EAS commands load app.config.ts, whose plugins must resolve. Keep install
772
- # scripts: some download native assets that the build's fingerprint check hashes.
773
- - name: Install mobile dependencies
774
- if: steps.record.outputs.built != 'true'
775
- run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile...
776
-
777
- - name: Setup EAS
778
- if: steps.record.outputs.built != 'true'
779
- uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
780
- with:
781
- eas-version: latest
782
- token: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
783
- packager: npm
784
-
785
- - name: Build tools
786
- if: steps.record.outputs.built != 'true'
787
- run: |
788
- command -v pod || sudo gem install cocoapods --no-document
789
- command -v fastlane || brew install fastlane
790
- pod --version
791
- fastlane --version | tail -1
792
-
793
- - name: Pull production environment variables
794
- if: steps.record.outputs.built != 'true'
795
- working-directory: apps/mobile
796
- run: eas env:pull production --non-interactive
797
-
589
- name: Build
590
if: steps.record.outputs.built != 'true'
800
- working-directory: apps/mobile
801
- env:
802
- # EAS secret variables don't reach local builds; the eas-build-on-success
803
- # hook needs these to upload the bundle's source map.
804
- MOBILE_SOURCEMAPS_R2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }}
805
- run: |
806
- # A real path: /var -> /private/var symlinks break the expo-widgets bundle step.
807
- export EAS_LOCAL_BUILD_WORKINGDIR="$RUNNER_TEMP/eas-build"
808
- eas build --local --platform ios --profile "$PROFILE" --non-interactive --output "$RUNNER_TEMP/t3code.ipa"
591
+ uses: ./.github/actions/eas-local-build
592
+ with:
593
+ platform: ios
594
+ profile: ${{ env.PROFILE }}
595
+ environment: production
596
+ expo-token: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
597
+ output: ${{ runner.temp }}/t3code.ipa
598
+ sourcemaps-r2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }}
599
600
- name: Submit to App Store Connect
601
if: steps.record.outputs.built != 'true'
@@ -816,23 +606,12 @@ jobs:
606
# pushed, the next merge rebuilds with a new build number; nothing is lost.
607
- name: Record build
608
if: steps.record.outputs.built != 'true'
819
- env:
820
- GH_TOKEN: ${{ github.token }}
609
+ uses: ./.github/actions/record-build-tag
610
+ with:
611
+ tag: ${{ env.BUILD_TAG }}
612
+ token: ${{ github.token }}
613
+
614
+ - name: Summarize
615
+ if: steps.record.outputs.built != 'true'
616
run: |
822
- sha="$(git rev-parse HEAD)"
823
- # GitHub occasionally fails ref writes server-side ("fatal error in commit_refs").
824
- for attempt in 1 2 3; do
825
- if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$BUILD_TAG" >/dev/null 2>&1; then
826
- echo "$BUILD_TAG exists."
827
- break
828
- fi
829
- if gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$BUILD_TAG" -f sha="$sha" >/dev/null; then
830
- break
831
- fi
832
- if [ "$attempt" = 3 ]; then
833
- echo "::error::Submitted, but could not create $BUILD_TAG; the next merge will rebuild."
834
- exit 1
835
- fi
836
- sleep $((attempt * 15))
837
- done
617
echo ":rocket: ios: submitted and recorded \`$BUILD_TAG\`" >> "$GITHUB_STEP_SUMMARY"