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
fix(ci): build iOS previews on Blacksmith with one mobile comment (#37568)
Julius Marminge committed
Nov 16, 2026 at 00:14 UTC
183029dee8ad9baeb8ef01d25d3fa2f6d4774e97
7 files changed
+698
-143
.github/scripts/mobile-ios-preview-record.cjs
new
+32
@@ -0,0 +1,32 @@
1
+const { readFileSync } = require("node:fs");
2
+
3
+function readClient(value, now = Date.now()) {
4
+ try {
5
+ const record = JSON.parse(value);
6
+ return typeof record?.link === "string" && Date.parse(record.expiresAt) > now
7
+ ? record.link
8
+ : "";
9
+ } catch {
10
+ return "";
11
+ }
12
+}
13
+
14
+function createRecord(link, profile) {
15
+ const expiration = /<key>ExpirationDate<\/key>\s*<date>([^<]+)<\/date>/.exec(profile)?.[1];
16
+ if (!expiration || !Number.isFinite(Date.parse(expiration))) {
17
+ throw new Error("The provisioning profile has no valid ExpirationDate.");
18
+ }
19
+ return JSON.stringify({ link, expiresAt: new Date(expiration).toISOString() });
20
+}
21
+
22
+if (require.main === module) {
23
+ if (process.argv[2] === "read") {
24
+ process.stdout.write(readClient(readFileSync(0, "utf8")));
25
+ } else if (process.argv[2] === "create") {
26
+ process.stdout.write(createRecord(process.argv[3], readFileSync(process.argv[4], "utf8")));
27
+ } else {
28
+ throw new Error("Expected read or create.");
29
+ }
30
+}
31
+
32
+module.exports = { createRecord, readClient };
.github/scripts/mobile-ios-preview-record.test.cjs
new
+17
@@ -0,0 +1,17 @@
1
+const assert = require("node:assert/strict");
2
+const test = require("node:test");
3
+const { createRecord, readClient } = require("./mobile-ios-preview-record.cjs");
4
+
5
+test("only clients with an unexpired provisioning profile are reused", () => {
6
+ const link = "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/client";
7
+ const profile =
8
+ "<plist><dict><key>ExpirationDate</key><date>2027-01-01T00:00:00Z</date></dict></plist>";
9
+ const record = createRecord(link, profile);
10
+ assert.equal(readClient(record, Date.parse("2026-12-31T00:00:00Z")), link);
11
+ assert.equal(readClient(record, Date.parse("2027-01-01T00:00:00Z")), "");
12
+ assert.equal(readClient(record, Date.parse("2027-01-02T00:00:00Z")), "");
13
+ for (const invalid of [link, "{}", "null", JSON.stringify({ link, expiresAt: "invalid" })]) {
14
+ assert.equal(readClient(invalid, 0), "");
15
+ }
16
+ assert.throws(() => createRecord(link, "<plist></plist>"), /ExpirationDate/);
17
+});
.github/scripts/mobile-preview-comment.cjs
+76
-46
@@ -1,21 +1,25 @@
1
-// The Android half of the mobile preview comment. The android job writes the fingerprint and
2
-// the update; the android-build job adds the client's install link a few minutes later. Each
3
-// run merges what it knows into the state kept in the comment's first line.
4
-const MARKER = "mobile-preview-android";
1
const PROJECT_ID = "d763fcb8-d37c-41ea-a773-b54a0ab4a454";
2
const APP_SCHEME = "t3-code";
3
4
function readState(body) {
9
- const match = new RegExp(`^<!-- ${MARKER} (\\{.*\\}) -->`).exec(body ?? "");
5
+ const match = /^<!-- mobile-preview(?:-(android|ios))? (\{.*\}) -->/.exec(body ?? "");
6
if (!match) return null;
7
try {
12
- const state = JSON.parse(match[1]);
8
+ const parsed = JSON.parse(match[2]);
9
+ const state = match[1] ? { [match[1]]: parsed } : parsed;
10
const text = (value) => (typeof value === "string" ? value : "");
14
- return {
15
- fingerprint: text(state.fingerprint),
16
- client: text(state.client),
17
- group: text(state.group),
18
- };
11
+ return Object.fromEntries(
12
+ ["android", "ios"]
13
+ .filter((platform) => state?.[platform])
14
+ .map((platform) => [
15
+ platform,
16
+ {
17
+ fingerprint: text(state[platform].fingerprint),
18
+ client: text(state[platform].client),
19
+ group: text(state[platform].group),
20
+ },
21
+ ]),
22
+ );
23
} catch {
24
return null;
25
}
@@ -46,22 +50,23 @@ function mergeState(previous, next) {
50
}
51
52
function render(state, runUrl) {
49
- const qr = `https://qr.expo.dev/eas-update?appScheme=${APP_SCHEME}&projectId=${PROJECT_ID}&groupId=${state.group}`;
53
+ const platforms = ["android", "ios"];
54
+ const cells = (value) => platforms.map((platform) => value(state[platform]));
55
const rows = [
51
- `<!-- ${MARKER} ${JSON.stringify(state)} -->`,
52
- "🤖 Android preview",
56
+ `<!-- mobile-preview ${JSON.stringify(state)} -->`,
57
+ "🚀 Mobile preview",
58
"",
54
- " | 🤖 Android",
55
- "--- | ---",
56
- `Fingerprint | ${state.fingerprint || "n/a"}`,
57
- `Dev client | ${state.client ? `[Install](${state.client})` : `Building on Blacksmith ([run](${runUrl})); this comment gets the install link when it finishes`}`,
59
+ " | 🤖 Android | 🍎 iOS",
60
+ "--- | --- | ---",
61
+ `Fingerprint | ${cells((entry) => entry?.fingerprint || "n/a").join(" | ")}`,
62
+ `Dev client | ${cells((entry) => (entry?.client ? `[Install](${entry.client})` : entry?.fingerprint ? `Client unavailable ([build run](${runUrl}))` : "n/a")).join(" | ")}`,
63
+ `Update Details | ${cells((entry) => (entry?.group ? `[Update Permalink](https://expo.dev/projects/${PROJECT_ID}/updates/${entry.group})` : "n/a")).join(" | ")}`,
64
+ `Update QR | ${cells((entry) => {
65
+ if (!entry?.group) return "n/a";
66
+ const qr = `https://qr.expo.dev/eas-update?appScheme=${APP_SCHEME}&projectId=${PROJECT_ID}&groupId=${entry.group}`;
67
+ return `<a href="${qr}"><img src="${qr}" width="250px" height="250px" /></a>`;
68
+ }).join(" | ")}`,
69
];
59
- if (state.group) {
60
- rows.push(
61
- `Update Details | [Update Permalink](https://expo.dev/projects/${PROJECT_ID}/updates/${state.group})`,
62
- `Update QR | <a href="${qr}"><img src="${qr}" width="250px" height="250px" /></a>`,
63
- );
64
- }
70
return rows.join("\n");
71
}
72
@@ -80,39 +85,64 @@ async function github(path, init = {}) {
85
`GitHub ${init.method ?? "GET"} ${path}: ${response.status} ${await response.text()}`,
86
);
87
}
83
- return response.json();
88
+ return response.status === 204 ? null : response.json();
89
}
90
86
-async function main() {
87
- const repository = process.env.GITHUB_REPOSITORY;
88
- const pr = process.env.PR;
89
- if (!repository || !pr || !process.env.GH_TOKEN) {
91
+async function main({ env = process.env, request = github } = {}) {
92
+ const repository = env.GITHUB_REPOSITORY;
93
+ const pr = env.PR;
94
+ if (!repository || !pr || !env.GH_TOKEN) {
95
throw new Error("GITHUB_REPOSITORY, PR and GH_TOKEN are required.");
96
}
92
- const runUrl = `${process.env.GITHUB_SERVER_URL}/${repository}/actions/runs/${process.env.GITHUB_RUN_ID}`;
93
- let existing = null;
94
- for (let page = 1; existing === null; page++) {
95
- const comments = await github(
97
+ if (!env.ANDROID_FINGERPRINT && !env.IOS_FINGERPRINT) return;
98
+ if (env.PR_HEAD_SHA) {
99
+ const pull = await request(`/repos/${repository}/pulls/${pr}`);
100
+ if (pull.head.sha !== env.PR_HEAD_SHA) return;
101
+ }
102
+ const runUrl = `${env.GITHUB_SERVER_URL}/${repository}/actions/runs/${env.GITHUB_RUN_ID}`;
103
+ const previews = [];
104
+ for (let page = 1; ; page++) {
105
+ const comments = await request(
106
`/repos/${repository}/issues/${pr}/comments?per_page=100&page=${page}`,
107
);
98
- // Only this workflow's own comment: anyone can post the marker, and nobody else's is editable.
99
- existing =
100
- comments.find(
108
+ previews.push(
109
+ ...comments.filter(
110
(comment) =>
102
- comment.user?.login === "github-actions[bot]" && readState(comment.body) !== null,
103
- ) ?? null;
111
+ comment.user?.login === "github-actions[bot]" &&
112
+ (readState(comment.body) !== null ||
113
+ comment.body?.startsWith(
114
+ `<!-- continuous-deploy-fingerprint-projectId:${PROJECT_ID} -->`,
115
+ )),
116
+ ),
117
+ );
118
if (comments.length < 100) break;
119
}
106
- const state = mergeState(readState(existing?.body), {
107
- fingerprint: process.env.FINGERPRINT ?? "",
108
- client: process.env.CLIENT ?? "",
109
- group: process.env.GROUP ?? "",
110
- });
120
+ const existing =
121
+ previews.find((comment) => comment.body.startsWith("<!-- mobile-preview ")) ?? previews[0];
122
+ const state = Object.assign(
123
+ {},
124
+ ...previews.map((comment) => readState(comment.body)),
125
+ readState(existing?.body),
126
+ );
127
+ for (const platform of ["android", "ios"]) {
128
+ const prefix = platform.toUpperCase();
129
+ const next = {
130
+ fingerprint: env[`${prefix}_FINGERPRINT`] ?? "",
131
+ client: env[`${prefix}_CLIENT`] ?? "",
132
+ group: env[`${prefix}_GROUP`] ?? "",
133
+ };
134
+ if (next.fingerprint) state[platform] = mergeState(state[platform], next);
135
+ }
136
const body = JSON.stringify({ body: render(state, runUrl) });
137
if (existing) {
113
- await github(`/repos/${repository}/issues/comments/${existing.id}`, { method: "PATCH", body });
138
+ await request(`/repos/${repository}/issues/comments/${existing.id}`, { method: "PATCH", body });
139
} else {
115
- await github(`/repos/${repository}/issues/${pr}/comments`, { method: "POST", body });
140
+ await request(`/repos/${repository}/issues/${pr}/comments`, { method: "POST", body });
141
+ }
142
+ for (const comment of previews) {
143
+ if (comment.id !== existing.id) {
144
+ await request(`/repos/${repository}/issues/comments/${comment.id}`, { method: "DELETE" });
145
+ }
146
}
147
}
148
@@ -123,4 +153,4 @@ if (require.main === module) {
153
});
154
}
155
126
-module.exports = { mergeState, readState, render };
156
+module.exports = { main, mergeState, readState, render };
.github/scripts/mobile-preview-comment.test.cjs
+94
-16
@@ -1,23 +1,22 @@
1
const assert = require("node:assert/strict");
2
const test = require("node:test");
3
4
-const { mergeState, readState, render } = require("./mobile-preview-comment.cjs");
4
+const { main, mergeState, readState, render } = require("./mobile-preview-comment.cjs");
5
6
const fingerprint = "c31608b37a8a2dca35ccee39cfd2ec7305042629";
7
const run = "https://github.com/pingdotgg/t3code/actions/runs/1";
8
9
test("the comment round-trips its state", () => {
10
- const state = { fingerprint, client: "", group: "8e413a0a" };
10
+ const state = {
11
+ android: { fingerprint, client: "", group: "8e413a0a" },
12
+ ios: { fingerprint: "ios-fingerprint", client: "https://expo.dev/ios", group: "ios-group" },
13
+ };
14
const body = render(state, run);
15
assert.deepEqual(readState(body), state);
13
- assert.match(
14
- body,
15
- /Building on Blacksmith \(\[run\]\(https:\/\/github\.com\/pingdotgg\/t3code\/actions\/runs\/1\)\)/,
16
- );
17
- assert.match(
18
- body,
19
- /qr\.expo\.dev\/eas-update\?appScheme=t3-code&projectId=[0-9a-f-]+&groupId=8e413a0a/,
20
- );
16
+ assert.match(body, /Client unavailable/);
17
+ assert.match(body, /groupId=8e413a0a/);
18
+ assert.match(body, /groupId=ios-group/);
19
+ assert.match(body, /\[Install\]\(https:\/\/expo.dev\/ios\)/);
20
assert.equal(readState("🚀 Expo continuous deployment is ready!"), null);
21
});
22
@@ -25,7 +24,10 @@ test("the build job adds the install link without losing the update", () => {
24
const first = mergeState(null, { fingerprint, client: "", group: "8e413a0a" });
25
const built = mergeState(first, { fingerprint, client: "https://expo.dev/a/b", group: "" });
26
assert.deepEqual(built, { fingerprint, client: "https://expo.dev/a/b", group: "8e413a0a" });
28
- assert.match(render(built, run), /Dev client \| \[Install\]\(https:\/\/expo\.dev\/a\/b\)/);
27
+ assert.match(
28
+ render({ android: built }, run),
29
+ /Dev client \| \[Install\]\(https:\/\/expo\.dev\/a\/b\)/,
30
+ );
31
});
32
33
test("a new fingerprint drops the old client; the same one keeps it", () => {
@@ -53,10 +55,86 @@ test("a build that finishes after the PR moved to another fingerprint changes no
55
test("state from the comment is always three strings", () => {
56
assert.deepEqual(
57
readState('<!-- mobile-preview-android {"fingerprint":5,"client":null} -->\nx'),
56
- {
57
- fingerprint: "",
58
- client: "",
59
- group: "",
60
- },
58
+ { android: { fingerprint: "", client: "", group: "" } },
59
);
60
});
61
+
62
+test("publishing consolidates platform comments and preserves unrelated comments", async () => {
63
+ const android = { fingerprint, client: "https://expo.dev/android", group: "android-group" };
64
+ const ios = {
65
+ fingerprint: "ios-fingerprint",
66
+ client: "https://expo.dev/ios",
67
+ group: "ios-group",
68
+ };
69
+ const comments = new Map([
70
+ [
71
+ 1,
72
+ {
73
+ id: 1,
74
+ user: { login: "github-actions[bot]" },
75
+ body: `<!-- mobile-preview-android ${JSON.stringify(android)} -->`,
76
+ },
77
+ ],
78
+ [
79
+ 2,
80
+ {
81
+ id: 2,
82
+ user: { login: "github-actions[bot]" },
83
+ body: `<!-- mobile-preview-ios ${JSON.stringify(ios)} -->`,
84
+ },
85
+ ],
86
+ [
87
+ 4,
88
+ {
89
+ id: 4,
90
+ user: { login: "github-actions[bot]" },
91
+ body: "<!-- continuous-deploy-fingerprint-projectId:d763fcb8-d37c-41ea-a773-b54a0ab4a454 -->\nOld Expo preview",
92
+ },
93
+ ],
94
+ [
95
+ 3,
96
+ {
97
+ id: 3,
98
+ user: { login: "contributor" },
99
+ body: `<!-- mobile-preview-ios ${JSON.stringify(ios)} -->`,
100
+ },
101
+ ],
102
+ ]);
103
+ await main({
104
+ env: {
105
+ GITHUB_REPOSITORY: "pingdotgg/t3code",
106
+ PR: "1",
107
+ GH_TOKEN: "test",
108
+ ANDROID_FINGERPRINT: fingerprint,
109
+ ANDROID_GROUP: "new-group",
110
+ },
111
+ request: async (path, init = {}) => {
112
+ if (!init.method) return [...comments.values()];
113
+ const id = Number(path.split("/").at(-1));
114
+ if (init.method === "DELETE") comments.delete(id);
115
+ else if (init.method === "PATCH") comments.get(id).body = JSON.parse(init.body).body;
116
+ else assert.fail("an existing preview should be reused");
117
+ },
118
+ });
119
+ assert.equal(comments.size, 2);
120
+ assert.deepEqual(readState(comments.get(1).body), {
121
+ android: { ...android, group: "new-group" },
122
+ ios,
123
+ });
124
+ assert.equal(comments.has(2), false);
125
+ assert.equal(comments.has(4), false);
126
+ assert.equal(comments.get(3).user.login, "contributor");
127
+ await main({
128
+ env: {
129
+ GITHUB_REPOSITORY: "pingdotgg/t3code",
130
+ PR: "1",
131
+ GH_TOKEN: "test",
132
+ ANDROID_FINGERPRINT: fingerprint,
133
+ PR_HEAD_SHA: "old-head",
134
+ },
135
+ request: async (path) => {
136
+ assert.equal(path, "/repos/pingdotgg/t3code/pulls/1");
137
+ return { head: { sha: "new-head" } };
138
+ },
139
+ });
140
+});
.github/workflows/ci.yml
+1
-1
@@ -326,7 +326,7 @@ jobs:
326
run: python3 -B .github/scripts/stage-preview-bundle.test.py
327
328
- name: Test release checks
329
- run: node --test .github/scripts/check-nightly-release.test.cjs .github/scripts/vercel-deployment-output.test.cjs .github/scripts/mobile-preview-comment.test.cjs .github/scripts/test-delta.test.cjs
329
+ run: node --test .github/scripts/check-nightly-release.test.cjs .github/scripts/vercel-deployment-output.test.cjs .github/scripts/mobile-preview-comment.test.cjs .github/scripts/mobile-ios-preview-record.test.cjs .github/scripts/test-delta.test.cjs
330
331
- name: Finish installing browser secret helper build libraries
332
timeout-minutes: 5
.github/workflows/mobile-eas-preview-fork.yml
+204
-30
@@ -1,8 +1,8 @@
1
name: Mobile EAS Preview (Fork)
2
3
# EAS previews for fork PRs. This runs the PR's code with an Expo token: the
4
-# app config and plugins run on this runner, the iOS client builds on EAS and
5
-# the Android one on Blacksmith (android-build), with preview signing credentials. The label is the maintainer's sign-off
4
+# app config and plugins run on this runner; both clients build on Blacksmith
5
+# with preview signing credentials. The label is the maintainer's sign-off
6
# that they reviewed that code, so it covers exactly the commit it was applied
7
# to: this pins that commit and consumes the label before running anything. A
8
# later push deploys nothing until the label is applied again.
@@ -30,6 +30,12 @@ jobs:
30
contents: read
31
pull-requests: write
32
outputs:
33
+ ios_group: ${{ steps.ios_update.outputs.group }}
34
+ ios_client: ${{ steps.ios_client.outputs.link }}
35
+ group: ${{ steps.update.outputs.group }}
36
+ client: ${{ steps.client.outputs.link }}
37
+ ios_build: ${{ steps.ios_client.outputs.build }}
38
+ ios_fingerprint: ${{ steps.ios_client.outputs.fingerprint }}
39
build: ${{ steps.client.outputs.build }}
40
fingerprint: ${{ steps.client.outputs.fingerprint }}
41
env:
@@ -140,8 +146,7 @@ jobs:
146
if: steps.expo-token.outputs.present == 'true'
147
uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
148
with:
143
- # Pinned and installed with npm for the same reasons as mobile-eas-preview.yml.
144
- eas-version: 21.8.0
149
+ eas-version: latest
150
eas-cache: false
151
token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
152
packager: npm
@@ -164,23 +169,40 @@ jobs:
169
}
170
NODE
171
167
- - name: Deploy with fingerprint check
172
+ - id: ios_client
173
+ name: Find the iOS client for this fingerprint
174
if: steps.expo-token.outputs.present == 'true'
169
- uses: expo/expo-github-action/continuous-deploy-fingerprint@5273c2136bd09c2a341fe3340d3e767ce5a13015 # v9.0.2
175
+ working-directory: apps/mobile
176
+ shell: bash
177
env:
178
EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
172
- RUNNER_DEBUG: "1"
173
- # The action only comments for pull_request events; this hook gives
174
- # it the PR under pull_request_target. Without it, it skips the comment.
175
- EXPO_TEST_GITHUB_PULL: ${{ github.event.pull_request.number }}
176
- with:
177
- profile: preview:dev
178
- branch: pr-${{ github.event.pull_request.number }}
179
- # Android is below: its client builds on Blacksmith (android-build).
180
- platform: ios
181
- environment: preview
182
- working-directory: apps/mobile
183
- github-token: ${{ secrets.GITHUB_TOKEN }}
179
+ run: |
180
+ 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)')"
181
+ echo "fingerprint=$hash" >> "$GITHUB_OUTPUT"
182
+ tag="mobile-ios-preview-build/$hash"
183
+ link=""
184
+ if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then
185
+ link="$(git tag -l --format='%(contents)' "$tag" | node "$GITHUB_WORKSPACE/.trusted/.github/scripts/mobile-ios-preview-record.cjs" read)"
186
+ fi
187
+ if [ -z "$link" ]; then
188
+ link="$(eas build:list --platform ios --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \
189
+ | sed -n '/^\[/,$p' \
190
+ | 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)"')"
191
+ fi
192
+ echo "link=$link" >> "$GITHUB_OUTPUT"
193
+ if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi
194
+
195
+ - id: ios_update
196
+ name: Publish the iOS update
197
+ if: steps.expo-token.outputs.present == 'true'
198
+ working-directory: apps/mobile
199
+ shell: bash
200
+ env:
201
+ EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
202
+ PR: ${{ github.event.pull_request.number }}
203
+ run: |
204
+ group="$(eas update --auto --branch "pr-$PR" --platform ios --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
205
+ echo "group=$group" >> "$GITHUB_OUTPUT"
206
207
# Android, as in mobile-eas-preview.yml: the same fingerprint command the Expo
208
# action runs. A client built for a same-repo PR (its tag) or by EAS is reused.
@@ -218,16 +240,6 @@ jobs:
240
group="$(eas update --auto --branch "pr-$PR" --platform android --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
241
echo "group=$group" >> "$GITHUB_OUTPUT"
242
221
- - name: Comment
222
- if: steps.expo-token.outputs.present == 'true'
223
- env:
224
- GH_TOKEN: ${{ github.token }}
225
- PR: ${{ github.event.pull_request.number }}
226
- FINGERPRINT: ${{ steps.client.outputs.fingerprint }}
227
- CLIENT: ${{ steps.client.outputs.link }}
228
- GROUP: ${{ steps.update.outputs.group }}
229
- run: node .trusted/.github/scripts/mobile-preview-comment.cjs
230
-
243
# The reviewed commit's Android client, built cold: no sticky disk, because PR
244
# code could leave Gradle or ccache state that trusted builds would restore, and
245
# no build record tag, so nobody else is served an APK a fork's code built.
@@ -240,6 +252,8 @@ jobs:
252
permissions:
253
contents: read
254
pull-requests: write
255
+ outputs:
256
+ client: ${{ steps.build.outputs.link }}
257
env:
258
APP_VARIANT: preview
259
NODE_OPTIONS: --max-old-space-size=8192
@@ -347,9 +361,169 @@ jobs:
361
fi
362
echo "link=$link" >> "$GITHUB_OUTPUT"
363
364
+ ios-build:
365
+ name: iOS preview client
366
+ needs: preview
367
+ if: needs.preview.outputs.ios_build == 'true'
368
+ runs-on: blacksmith-12vcpu-macos-27
369
+ timeout-minutes: 60
370
+ permissions:
371
+ contents: read
372
+ pull-requests: write
373
+ outputs:
374
+ client: ${{ steps.build.outputs.link }}
375
+ env:
376
+ APP_VARIANT: preview
377
+ NODE_OPTIONS: --max-old-space-size=8192
378
+ MOBILE_VERSION_POLICY: fingerprint
379
+ FINGERPRINT: ${{ needs.preview.outputs.ios_fingerprint }}
380
+ steps:
381
+ - name: Checkout reviewed commit
382
+ uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
383
+ with:
384
+ ref: ${{ github.event.pull_request.head.sha }}
385
+ fetch-depth: 0
386
+
387
+ # The comment script comes from main, not from the PR.
388
+ - name: Checkout trusted scripts
389
+ uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
390
+ with:
391
+ path: .trusted
392
+ sparse-checkout: .github/scripts
393
+
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).
398
+ - 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...
452
+
453
+ - name: Setup EAS
454
+ uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
455
+ 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
483
+
484
+ - id: build
485
+ name: Build and upload
486
+ working-directory: apps/mobile
487
+ shell: bash
488
+ env:
489
+ EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
490
+ 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"
493
+ eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
494
+ link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
495
+ if [ -z "$link" ]; then
496
+ echo "::error::eas upload returned no install link"
497
+ exit 1
498
+ fi
499
+ echo "link=$link" >> "$GITHUB_OUTPUT"
500
+
501
+ comment:
502
+ name: Mobile preview comment
503
+ needs: [preview, android-build, ios-build]
504
+ if: always() && !cancelled() && needs.preview.result == 'success'
505
+ runs-on: blacksmith-2vcpu-ubuntu-2404
506
+ concurrency:
507
+ group: mobile-preview-comment-${{ github.event.pull_request.number }}
508
+ cancel-in-progress: false
509
+ permissions:
510
+ contents: read
511
+ pull-requests: write
512
+ steps:
513
+ - name: Checkout comment script
514
+ uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
515
+ with:
516
+ sparse-checkout: .github/scripts
517
+
518
- name: Comment
519
env:
520
GH_TOKEN: ${{ github.token }}
521
PR: ${{ github.event.pull_request.number }}
354
- CLIENT: ${{ steps.build.outputs.link }}
355
- run: node .trusted/.github/scripts/mobile-preview-comment.cjs
522
+ PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
523
+ ANDROID_FINGERPRINT: ${{ needs.preview.outputs.fingerprint }}
524
+ ANDROID_GROUP: ${{ needs.preview.outputs.group }}
525
+ ANDROID_CLIENT: ${{ needs.android-build.outputs.client || needs.preview.outputs.client }}
526
+ IOS_FINGERPRINT: ${{ needs.preview.outputs.ios_fingerprint }}
527
+ IOS_GROUP: ${{ needs.preview.outputs.ios_group }}
528
+ IOS_CLIENT: ${{ needs.ios-build.outputs.client || needs.preview.outputs.ios_client }}
529
+ run: node .github/scripts/mobile-preview-comment.cjs
.github/workflows/mobile-eas-preview.yml
+274
-50
@@ -5,35 +5,40 @@ on:
5
types: [opened, reopened, synchronize, labeled]
6
7
jobs:
8
- preview:
8
+ ios:
9
name: EAS Preview (iOS)
10
- # Fork PRs deploy one reviewed commit per label through mobile-eas-preview-fork.yml.
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:
17
- group: mobile-eas-preview-${{ github.event.pull_request.number }}
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
29
- env:
30
- EXPO_TOKEN: ${{ secrets.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"
36
- echo "EXPO_PREVIEW_TOKEN is not available; skipping EAS preview."
41
+ echo "EXPO_PREVIEW_TOKEN is not available; skipping the iOS preview."
42
fi
43
44
- name: Checkout
@@ -41,10 +46,33 @@ jobs:
46
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
47
with:
48
fetch-depth: 0
44
- # No sparse-checkout here: it makes actions/checkout fetch with
45
- # --filter=blob:none, and eas-cli archives the project via
46
- # `git clone --depth 1 file://<workspace>`, which fails (exit 128)
47
- # when the partial clone can't serve the unfetched blobs.
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'
@@ -68,25 +96,15 @@ jobs:
96
if: steps.expo-token.outputs.present == 'true'
97
uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
98
with:
71
- # eas-cli 22 renamed `project` to `app` in build JSON, and
72
- # continuous-deploy-fingerprint still reads `build.project.ownerAccount`.
73
- # Unpin once https://github.com/expo/expo-github-action/issues/358 is fixed.
74
- eas-version: 21.8.0
99
+ eas-version: latest
100
token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
76
- # npm, not pnpm: this only installs eas-cli into the action's own
77
- # tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
78
- # ignored build script (no allowBuilds config outside the repo).
101
packager: npm
102
103
- name: Pull preview environment variables
104
if: steps.expo-token.outputs.present == 'true'
105
working-directory: apps/mobile
84
- env:
85
- EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
106
run: |
107
eas env:pull preview --non-interactive
88
- # EAS Update disables dotenv loading. Keep the downloaded native config
89
- # in its process environment so Android build and OTA fingerprints match.
108
node --input-type=module <<'NODE'
109
import { appendFileSync, readFileSync } from "node:fs";
110
import { parseEnv } from "node:util";
@@ -97,27 +115,40 @@ jobs:
115
}
116
NODE
117
100
- - name: Deploy with fingerprint check
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'
102
- uses: expo/expo-github-action/continuous-deploy-fingerprint@5273c2136bd09c2a341fe3340d3e767ce5a13015 # v9.0.2
103
- env:
104
- EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
105
- # The Expo action otherwise suppresses the EAS command's failure output.
106
- RUNNER_DEBUG: "1"
107
- with:
108
- profile: preview:dev
109
- branch: pr-${{ github.event.pull_request.number }}
110
- # Android is the android job below: its client builds on Blacksmith.
111
- platform: ios
112
- environment: preview
113
- working-directory: apps/mobile
114
- github-token: ${{ secrets.GITHUB_TOKEN }}
115
-
116
- # Android publishes its own update and comment, because the Expo action can only
117
- # find a client that EAS built. A fingerprint with no client is built by
118
- # android-build with `eas build --local` on Blacksmith (about 4 minutes warm,
119
- # against about 40 on EAS) and recorded as a mobile-android-preview-build/<fingerprint>
120
- # tag whose message is the install link. Clients EAS built earlier still count.
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: |
@@ -132,6 +163,8 @@ jobs:
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:
@@ -258,14 +291,6 @@ jobs:
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
261
- - name: Comment
262
- if: steps.expo-token.outputs.present == 'true'
263
- env:
264
- FINGERPRINT: ${{ steps.client.outputs.fingerprint }}
265
- CLIENT: ${{ steps.client.outputs.link }}
266
- GROUP: ${{ steps.update.outputs.group }}
267
- run: node .github/scripts/mobile-preview-comment.cjs
268
-
294
android-build:
295
name: Android preview client
296
needs: android
@@ -276,9 +301,12 @@ jobs:
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
@@ -447,9 +475,205 @@ jobs:
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 }}
454
- CLIENT: ${{ steps.build.outputs.link || steps.record.outputs.link }}
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