Open History to see the last commit
1name: Mobile EAS Preview
2β
3on:
4 pull_request:
5 types: [opened, reopened, synchronize, labeled]
6β
7jobs:
8 ios:
9 name: EAS Preview (iOS)
10 if: |
11 github.event.pull_request.head.repo.full_name == github.repository &&
12 contains(github.event.pull_request.labels.*.name, 'π Mobile Continuous Deployment') &&
13 (github.event.action != 'labeled' || github.event.label.name == 'π Mobile Continuous Deployment')
14 runs-on: blacksmith-8vcpu-ubuntu-2404
15 concurrency:
16 group: mobile-eas-preview-ios-${{ github.event.pull_request.number }}
17 cancel-in-progress: true
18 permissions:
19 contents: read
20 pull-requests: write
21 outputs:
22 group: ${{ steps.update.outputs.group }}
23 client: ${{ steps.client.outputs.link }}
24 build: ${{ steps.client.outputs.build }}
25 fingerprint: ${{ steps.client.outputs.fingerprint }}
26 env:
27 APP_VARIANT: preview
28 NODE_OPTIONS: --max-old-space-size=8192
29 MOBILE_VERSION_POLICY: fingerprint
30 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
31 GH_TOKEN: ${{ github.token }}
32 PR: ${{ github.event.pull_request.number }}
33 steps:
34 - id: expo-token
35 name: Check for EXPO_PREVIEW_TOKEN
36 run: |
37 if [ -n "$EXPO_TOKEN" ]; then
38 echo "present=true" >> "$GITHUB_OUTPUT"
39 else
40 echo "present=false" >> "$GITHUB_OUTPUT"
41 echo "EXPO_PREVIEW_TOKEN is not available; skipping the iOS preview."
42 fi
43β
44 - name: Checkout
45 if: steps.expo-token.outputs.present == 'true'
46 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
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).
54 - name: Drop checkout credentials
55 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
76β
77 - name: Setup Vite+
78 if: steps.expo-token.outputs.present == 'true'
79 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
80 with:
81 node-version-file: package.json
82 cache: true
83 run-install: |
84 args:
85 - --filter=@t3tools/mobile...
86β
87 - name: Expose pnpm
88 if: steps.expo-token.outputs.present == 'true'
89 run: |
90 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
91 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
92 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
93 "$vp_pnpm_bin/pnpm" --version
94β
95 - name: Setup EAS
96 if: steps.expo-token.outputs.present == 'true'
97 uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
98 with:
99 eas-version: latest
100 token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
101 packager: npm
102β
103 - name: Pull preview environment variables
104 if: steps.expo-token.outputs.present == 'true'
105 working-directory: apps/mobile
106 run: |
107 eas env:pull preview --non-interactive
108 node --input-type=module <<'NODE'
109 import { appendFileSync, readFileSync } from "node:fs";
110 import { parseEnv } from "node:util";
111 const env = parseEnv(readFileSync(".env.local", "utf8"));
112 const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
113 if (googleServicesFile) {
114 appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
115 }
116 NODE
117β
118 # The same command the Expo action runs, so this is the runtime version the update gets.
119 - id: client
120 name: Find the client for this fingerprint
121 if: steps.expo-token.outputs.present == 'true'
122 working-directory: apps/mobile
123 shell: bash
124 run: |
125 hash="$(eas env:exec --non-interactive preview "npx expo-updates fingerprint:generate --platform ios" | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
126 echo "fingerprint=$hash" >> "$GITHUB_OUTPUT"
127 tag="mobile-ios-preview-build/$hash"
128 link=""
129 if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then
130 link="$(git tag -l --format='%(contents)' "$tag" | node "$GITHUB_WORKSPACE/.github/scripts/mobile-ios-preview-record.cjs" read)"
131 fi
132 if [ -z "$link" ]; then
133 # A client EAS built before this job existed; expired ones are gone.
134 link="$(eas build:list --platform ios --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \
135 | sed -n '/^\[/,$p' \
136 | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '[.[] | select((.expirationDate // "9999") > $now)][0] | select(. != null) | "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/\(.id)"')"
137 fi
138 echo "link=$link" >> "$GITHUB_OUTPUT"
139 if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi
140 echo "ios fingerprint \`$hash\`: ${link:-no client yet, building on Blacksmith}" >> "$GITHUB_STEP_SUMMARY"
141β
142 - id: update
143 name: Publish the update
144 if: steps.expo-token.outputs.present == 'true'
145 working-directory: apps/mobile
146 shell: bash
147 run: |
148 group="$(eas update --auto --branch "pr-$PR" --platform ios --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
149 echo "group=$group" >> "$GITHUB_OUTPUT"
150β
151 # Preview build tags store the install link for each fingerprint; older EAS clients also count.
152 android:
153 name: EAS Preview (Android)
154 if: |
155 github.event.pull_request.head.repo.full_name == github.repository &&
156 contains(github.event.pull_request.labels.*.name, 'π Mobile Continuous Deployment') &&
157 (github.event.action != 'labeled' || github.event.label.name == 'π Mobile Continuous Deployment')
158 runs-on: blacksmith-8vcpu-ubuntu-2404
159 concurrency:
160 group: mobile-eas-preview-android-${{ github.event.pull_request.number }}
161 cancel-in-progress: true
162 permissions:
163 contents: read
164 pull-requests: write
165 outputs:
166 group: ${{ steps.update.outputs.group }}
167 client: ${{ steps.client.outputs.link }}
168 build: ${{ steps.client.outputs.build }}
169 fingerprint: ${{ steps.client.outputs.fingerprint }}
170 env:
171 APP_VARIANT: preview
172 NODE_OPTIONS: --max-old-space-size=8192
173 MOBILE_VERSION_POLICY: fingerprint
174 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
175 GH_TOKEN: ${{ github.token }}
176 PR: ${{ github.event.pull_request.number }}
177 steps:
178 - id: expo-token
179 name: Check for EXPO_PREVIEW_TOKEN
180 run: |
181 if [ -n "$EXPO_TOKEN" ]; then
182 echo "present=true" >> "$GITHUB_OUTPUT"
183 else
184 echo "present=false" >> "$GITHUB_OUTPUT"
185 echo "EXPO_PREVIEW_TOKEN is not available; skipping the Android preview."
186 fi
187β
188 - name: Checkout
189 if: steps.expo-token.outputs.present == 'true'
190 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
191 with:
192 fetch-depth: 0
193β
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).
198 - name: Drop checkout credentials
199 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
220β
221 - name: Setup Vite+
222 if: steps.expo-token.outputs.present == 'true'
223 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
224 with:
225 node-version-file: package.json
226 cache: true
227 run-install: |
228 args:
229 - --filter=@t3tools/mobile...
230β
231 - name: Expose pnpm
232 if: steps.expo-token.outputs.present == 'true'
233 run: |
234 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
235 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
236 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
237 "$vp_pnpm_bin/pnpm" --version
238β
239 - name: Setup EAS
240 if: steps.expo-token.outputs.present == 'true'
241 uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
242 with:
243 eas-version: latest
244 token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
245 packager: npm
246β
247 - name: Pull preview environment variables
248 if: steps.expo-token.outputs.present == 'true'
249 working-directory: apps/mobile
250 run: |
251 eas env:pull preview --non-interactive
252 node --input-type=module <<'NODE'
253 import { appendFileSync, readFileSync } from "node:fs";
254 import { parseEnv } from "node:util";
255 const env = parseEnv(readFileSync(".env.local", "utf8"));
256 const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
257 if (googleServicesFile) {
258 appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
259 }
260 NODE
261β
262 # The same command the Expo action runs, so this is the runtime version the update gets.
263 - id: client
264 name: Find the client for this fingerprint
265 if: steps.expo-token.outputs.present == 'true'
266 working-directory: apps/mobile
267 shell: bash
268 run: |
269 hash="$(eas env:exec --non-interactive preview "npx expo-updates fingerprint:generate --platform android" | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
270 echo "fingerprint=$hash" >> "$GITHUB_OUTPUT"
271 tag="mobile-android-preview-build/$hash"
272 link=""
273 if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then
274 link="$(git tag -l --format='%(contents:subject)' "$tag")"
275 else
276 # A client EAS built before this job existed; expired ones are gone.
277 link="$(eas build:list --platform android --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \
278 | sed -n '/^\[/,$p' \
279 | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '[.[] | select((.expirationDate // "9999") > $now)][0] | select(. != null) | "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/\(.id)"')"
280 fi
281 echo "link=$link" >> "$GITHUB_OUTPUT"
282 if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi
283 echo "android fingerprint \`$hash\`: ${link:-no client yet, building on Blacksmith}" >> "$GITHUB_STEP_SUMMARY"
284β
285 - id: update
286 name: Publish the update
287 if: steps.expo-token.outputs.present == 'true'
288 working-directory: apps/mobile
289 shell: bash
290 run: |
291 group="$(eas update --auto --branch "pr-$PR" --platform android --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
292 echo "group=$group" >> "$GITHUB_OUTPUT"
293β
294 android-build:
295 name: Android preview client
296 needs: android
297 if: needs.android.outputs.build == 'true'
298 runs-on: blacksmith-32vcpu-ubuntu-2404
299 timeout-minutes: 60
300 concurrency:
301 # One build per fingerprint; a second PR with the same one finds the tag.
302 group: mobile-android-preview-build-${{ needs.android.outputs.fingerprint }}
303 cancel-in-progress: false
304 queue: max
305 permissions:
306 contents: write # pushes the build record tag
307 pull-requests: write
308 outputs:
309 client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
310 env:
311 APP_VARIANT: preview
312 NODE_OPTIONS: --max-old-space-size=8192
313 MOBILE_VERSION_POLICY: fingerprint
314 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
315 FINGERPRINT: ${{ needs.android.outputs.fingerprint }}
316 BUILD_TAG: mobile-android-preview-build/${{ needs.android.outputs.fingerprint }}
317 # Phones only: emulators use the development client from the native-client cache.
318 ORG_GRADLE_PROJECT_reactNativeArchitectures: armeabi-v7a,arm64-v8a
319 steps:
320 - name: Checkout
321 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
322 with:
323 fetch-depth: 0
324β
325 - id: record
326 name: Check build record
327 run: |
328 if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
329 echo "built=true" >> "$GITHUB_OUTPUT"
330 echo "link=$(git tag -l --format='%(contents:subject)' "$BUILD_TAG")" >> "$GITHUB_OUTPUT"
331 fi
332β
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).
337 - 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
358β
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
379 if: steps.record.outputs.built != 'true'
380 uses: useblacksmith/stickydisk@3f6be1451e3cad893b778bc93495c80452a5da26 # v1.7.2
381 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
442β
443 # `eas upload` hosts the APK on EAS and returns the page testers install from.
444 - id: build
445 name: Build and upload
446 if: steps.record.outputs.built != 'true'
447 working-directory: apps/mobile
448 shell: bash
449 run: |
450 eas build --local --platform android --profile preview:dev --non-interactive --output "$RUNNER_TEMP/t3code-preview.apk"
451 eas upload --platform android --build-path "$RUNNER_TEMP/t3code-preview.apk" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
452 link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
453 if [ -z "$link" ]; then
454 echo "::error::eas upload returned no install link"
455 exit 1
456 fi
457 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"
464β
465 # The tag is the record later runs look up; its message is the install link.
466 - name: Record build
467 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"
477β
478 ios-build:
479 name: iOS preview client
480 needs: ios
481 if: needs.ios.outputs.build == 'true'
482 runs-on: blacksmith-12vcpu-macos-27
483 timeout-minutes: 60
484 concurrency:
485 # One build per fingerprint; a second PR with the same one finds the tag.
486 group: mobile-ios-preview-build-${{ needs.ios.outputs.fingerprint }}
487 cancel-in-progress: false
488 queue: max
489 permissions:
490 contents: write # pushes the build record tag
491 pull-requests: write
492 outputs:
493 client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
494 env:
495 APP_VARIANT: preview
496 NODE_OPTIONS: --max-old-space-size=8192
497 MOBILE_VERSION_POLICY: fingerprint
498 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
499 FINGERPRINT: ${{ needs.ios.outputs.fingerprint }}
500 BUILD_TAG: mobile-ios-preview-build/${{ needs.ios.outputs.fingerprint }}
501 steps:
502 - name: Checkout
503 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
504 with:
505 fetch-depth: 0
506β
507 - name: Setup Node
508 uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
509 with:
510 node-version-file: package.json
511β
512 - id: record
513 name: Check build record
514 run: |
515 if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
516 link="$(git tag -l --format='%(contents)' "$BUILD_TAG" | node .github/scripts/mobile-ios-preview-record.cjs read)"
517 if [ -n "$link" ]; then
518 echo "built=true" >> "$GITHUB_OUTPUT"
519 echo "link=$link" >> "$GITHUB_OUTPUT"
520 fi
521 fi
522β
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).
527 - 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"
561β
562 # EAS's credentials step fails to import the distribution certificate without it.
563 - name: Install Apple WWDR G3 intermediate
564 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
584 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
611β
612 # EAS hosts the signed client and returns its install page.
613 - id: build
614 name: Build and upload
615 if: steps.record.outputs.built != 'true'
616 working-directory: apps/mobile
617 shell: bash
618 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"
621 eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
622 link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
623 if [ -z "$link" ]; then
624 echo "::error::eas upload returned no install link"
625 exit 1
626 fi
627 echo "link=$link" >> "$GITHUB_OUTPUT"
628 {
629 echo "### iOS preview client for \`$FINGERPRINT\`: $link"
630 } >> "$GITHUB_STEP_SUMMARY"
631β
632 # The tag stores the install link and provisioning-profile expiry.
633 - name: Record build
634 if: steps.record.outputs.built != 'true'
635 env:
636 LINK: ${{ steps.build.outputs.link }}
637 GH_TOKEN: ${{ github.token }}
638 run: |
639 git config user.name "github-actions[bot]"
640 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
641 profile_path="$(unzip -Z -1 "$RUNNER_TEMP/t3code-preview.ipa" | awk '/^Payload\/[^/]+\.app\/embedded.mobileprovision$/')"
642 test -n "$profile_path"
643 unzip -p "$RUNNER_TEMP/t3code-preview.ipa" "$profile_path" > "$RUNNER_TEMP/preview.mobileprovision"
644 security cms -D -i "$RUNNER_TEMP/preview.mobileprovision" > "$RUNNER_TEMP/preview-profile.plist"
645 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"
650β
651 comment:
652 name: Mobile preview comment
653 needs: [android, ios, android-build, ios-build]
654 if: always() && !cancelled() && (needs.android.result == 'success' || needs.ios.result == 'success')
655 runs-on: blacksmith-2vcpu-ubuntu-2404
656 concurrency:
657 group: mobile-preview-comment-${{ github.event.pull_request.number }}
658 cancel-in-progress: false
659 permissions:
660 contents: read
661 pull-requests: write
662 steps:
663 - name: Checkout comment script
664 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
665 with:
666 sparse-checkout: .github/scripts
667β
668 - name: Comment
669 env:
670 GH_TOKEN: ${{ github.token }}
671 PR: ${{ github.event.pull_request.number }}
672 PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
673 ANDROID_FINGERPRINT: ${{ needs.android.outputs.fingerprint }}
674 ANDROID_GROUP: ${{ needs.android.outputs.group }}
675 ANDROID_CLIENT: ${{ needs.android-build.outputs.client || needs.android.outputs.client }}
676 IOS_FINGERPRINT: ${{ needs.ios.outputs.fingerprint }}
677 IOS_GROUP: ${{ needs.ios.outputs.group }}
678 IOS_CLIENT: ${{ needs.ios-build.outputs.client || needs.ios.outputs.client }}
679 run: node .github/scripts/mobile-preview-comment.cjs