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, 16:00 UTC
fix(ci): macOS PR previews no longer run the PR's bundle next to signing secrets (#36407)
Julius Marminge committed
Nov 13, 2026 at 13:55 UTC
dd2678d6e82aafae930dc9943bc96083031be10f
6 files changed
+87
-3
.github/workflows/desktop-macos-preview-publish.yml
+1
@@ -316,6 +316,7 @@ jobs:
316
rust_target: aarch64-apple-darwin
317
resource_key: darwin-arm64
318
cli_archive: false
319
+ untrusted_bundle: true
320
321
# Release assets download without a GitHub account, unlike workflow
322
# artifacts. All preview DMGs live on one rolling prerelease tagged
.github/workflows/release-desktop.yml
+15
@@ -70,6 +70,12 @@ on:
70
required: false
71
default: false
72
type: boolean
73
+ # Whether the JS bundle came from a pull request. This job holds the
74
+ # signing secrets, so packaging then skips every step that runs the bundle.
75
+ untrusted_bundle:
76
+ required: false
77
+ default: false
78
+ type: boolean
79
# A runner of the target's own platform and architecture, for a `runner`
80
# that cannot execute the target. The build job skips everything that
81
# runs the packaged binaries, and a second job runs it there.
@@ -134,6 +140,14 @@ jobs:
140
T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ inputs.clerk_cli_oauth_client_id }}
141
T3CODE_RELAY_URL: ${{ inputs.relay_url }}
142
steps:
143
+ # The launch check and the CLI archive smoke test both run the bundle.
144
+ - name: Reject running an untrusted bundle
145
+ if: inputs.untrusted_bundle && (inputs.launch_check || inputs.cli_archive)
146
+ shell: bash
147
+ run: |
148
+ echo "::error::untrusted_bundle cannot be combined with launch_check or cli_archive, which run the bundle."
149
+ exit 1
150
+
151
# This repository is public, so Git needs no credentials. checkout's
152
# credential cleanup runs submodule foreach even with submodules disabled,
153
# which fails on the orphaned gitlinks in our vendored .repos tree.
@@ -573,6 +587,7 @@ jobs:
587
pnpm_config_prefer_offline: "true"
588
T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
589
T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
590
+ T3CODE_DESKTOP_UNTRUSTED_BUNDLE: ${{ inputs.untrusted_bundle }}
591
CSC_LINK: ${{ secrets.CSC_LINK }}
592
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
593
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
scripts/build-desktop-artifact.test.ts
+52
@@ -19,6 +19,7 @@ import * as Sink from "effect/Sink";
19
import * as Schema from "effect/Schema";
20
import * as Stream from "effect/Stream";
21
import { ChildProcess, ChildProcessSpawner } from "effect/process";
22
+import { fromYaml } from "@t3tools/shared/schemaYaml";
23
24
import {
25
buildDesktopBundles,
@@ -1430,6 +1431,57 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
1431
),
1432
);
1433
1434
+ it.effect("never runs an untrusted macOS bundle", () =>
1435
+ Effect.scoped(
1436
+ Effect.gen(function* () {
1437
+ const fs = yield* FileSystem.FileSystem;
1438
+ const path = yield* Path.Path;
1439
+ const marker = path.join(yield* fs.makeTempDirectoryScoped(), "ran");
1440
+ const fixture = yield* makePackagedAppFixture({
1441
+ serverEntrySource: `import { writeFileSync } from "node:fs";\nwriteFileSync(${JSON.stringify(marker)}, "");\n`,
1442
+ });
1443
+ yield* validateMacPackagedPayload({ stageDistDir: fixture.stageDistDir });
1444
+ assert.isFalse(yield* fs.exists(marker));
1445
+ }),
1446
+ ).pipe(
1447
+ Effect.provide(
1448
+ ConfigProvider.layer(
1449
+ ConfigProvider.fromEnv({ env: { T3CODE_DESKTOP_UNTRUSTED_BUNDLE: "true" } }),
1450
+ ),
1451
+ ),
1452
+ ),
1453
+ );
1454
+
1455
+ it.effect("packages the macOS preview's PR bundle as untrusted", () =>
1456
+ Effect.gen(function* () {
1457
+ const fs = yield* FileSystem.FileSystem;
1458
+ const path = yield* Path.Path;
1459
+ const workflow = yield* fs.readFileString(
1460
+ yield* path.fromFileUrl(
1461
+ new URL("../.github/workflows/desktop-macos-preview-publish.yml", import.meta.url),
1462
+ ),
1463
+ );
1464
+ const { jobs } = yield* Schema.decodeEffect(
1465
+ fromYaml(
1466
+ Schema.Struct({
1467
+ jobs: Schema.Record(
1468
+ Schema.String,
1469
+ Schema.Struct({
1470
+ uses: Schema.optional(Schema.String),
1471
+ with: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
1472
+ }),
1473
+ ),
1474
+ }),
1475
+ ),
1476
+ )(workflow);
1477
+ const packaging = Object.values(jobs).filter(
1478
+ (job) => job.uses === "./.github/workflows/release-desktop.yml",
1479
+ );
1480
+ assert.isNotEmpty(packaging);
1481
+ for (const job of packaging) assert.strictEqual(job.with?.untrusted_bundle, true);
1482
+ }),
1483
+ );
1484
+
1485
it.effect("rejects a macOS stage without a packaged app", () =>
1486
Effect.scoped(
1487
Effect.gen(function* () {
scripts/build-desktop-artifact.ts
+7
@@ -2212,6 +2212,13 @@ export const copyDirectoryPreservingSymlinks = Effect.fn("copyDirectoryPreservin
2212
2213
export const verifyPackagedBundleIsSelfContained = Effect.fn("verifyPackagedBundleIsSelfContained")(
2214
function* (input: { readonly asarPath: string; readonly verbose: boolean }) {
2215
+ // A PR preview's bundle is untrusted and this job may hold signing secrets, so never run it.
2216
+ if (yield* Config.Boolean("T3CODE_DESKTOP_UNTRUSTED_BUNDLE").pipe(Config.withDefault(false))) {
2217
+ yield* Effect.log(
2218
+ "[desktop-artifact] Skipped the bundle self-check for an untrusted bundle.",
2219
+ );
2220
+ return;
2221
+ }
2222
const fs = yield* FileSystem.FileSystem;
2223
const path = yield* Path.Path;
2224
scripts/lib/server-compile-cache.test.ts
+7
-3
@@ -10,9 +10,10 @@ it.each([
10
{ platform: "freebsd", hostArch: "x64", arch: 1, reason: "unsupported target freebsd" },
11
{ platform: "linux", hostArch: "x64", arch: 3, reason: "unexecutable target linux/arm64" },
12
{ platform: "linux", hostArch: "arm64", arch: 1, reason: "unexecutable target linux/x64" },
13
+ { platform: "darwin", hostArch: "arm64", arch: 3, reason: "untrusted bundle", untrusted: true },
14
])(
14
- "skips unsupported $platform/$hostArch cache generation",
15
- async ({ platform, hostArch, arch, reason }) => {
15
+ "skips cache generation for $reason",
16
+ async ({ platform, hostArch, arch, reason, untrusted }) => {
17
const { spawnSync } = await import("node:child_process");
18
const hook = NodeURL.fileURLToPath(
19
new URL("../prepare-server-compile-cache.cjs", import.meta.url),
@@ -25,7 +26,10 @@ it.each([
26
Object.defineProperty(process, "arch", { value: ${JSON.stringify(hostArch)} });
27
require(${JSON.stringify(hook)})({ electronPlatformName: ${JSON.stringify(platform)}, arch: ${arch} }).catch(error => { console.error(error); process.exitCode = 1; });`,
28
],
28
- { encoding: "utf8" },
29
+ {
30
+ encoding: "utf8",
31
+ env: { ...process.env, T3CODE_DESKTOP_UNTRUSTED_BUNDLE: untrusted ? "true" : "" },
32
+ },
33
);
34
expect(result.status, result.stderr).toBe(0);
35
expect(result.stdout).toContain(`Skipping ${reason}`);
scripts/prepare-server-compile-cache.cjs
+5
@@ -10,6 +10,11 @@ module.exports = async ({ appOutDir, electronPlatformName, arch, packager }) =>
10
console.log(`[server-compile-cache] Skipping unsupported target ${electronPlatformName}`);
11
return;
12
}
13
+ // Generating the cache runs the bundle, and a PR preview's bundle must never run next to signing secrets.
14
+ if (process.env.T3CODE_DESKTOP_UNTRUSTED_BUNDLE === "true") {
15
+ console.log("[server-compile-cache] Skipping untrusted bundle");
16
+ return;
17
+ }
18
const targetArch = ["ia32", "x64", "armv7l", "arm64", "universal"][arch];
19
const runsWithRosetta =
20
electronPlatformName === "darwin" &&