ci(release): build, sign, and publish self-contained CLI archives #11317
sea/bundle-loaders fromrefs/pull/11317/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- .github/workflows/release.yml line 737OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -710,3 +728,10 @@710728711729 vp run dist:desktop:artifact "${args[@]}"712730731+ # The single-executable is built with a Node that supports --build-sea732+ # (25.7+); the repo itself stays on the engines.node version.733+ - name: Build CLI single-executable734+ shell: bash735+ env:736+ VP_NODE_VERSION: "26"737+ run: vp run --filter t3 build:exeapps/server/src/cli/invocation.ts lines 46 to 46OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -43,4 +43,4 @@4343 * anything else suggests the bare package.4444 */4545 function suggestedPackageSpec(version: string): string {46- return version.includes("-nightly.") ? "t3@nightly" : "t3";46+ const channel = /-(nightly|preview)\./.exec(version)?.[1];scripts/smoke-cli-archive.ts lines 51 to 51OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +31,21 @@31+32+const collect = <E>(stream: Stream.Stream<Uint8Array, E>) =>33+ stream.pipe(34+ Stream.decodeText(),35+ Stream.runFold(36+ () => "",37+ (acc, chunk) => acc + chunk,38+ ),39+ );40+41+const runExecutable = Effect.fn("runExecutable")(function* (42+ executable: string,43+ args: ReadonlyArray<string>,44+ cwd: string,45+) {46+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;47+ const child = yield* spawner.spawn(48+ ChildProcess.make(executable, args, {49+ cwd,50+ // The service launcher context must not leak in from a developer shell.51+ env: { PATH: process.env.PATH ?? "", HOME: cwd, USERPROFILE: cwd, TMPDIR: cwd, TEMP: cwd },scripts/smoke-cli-archive.ts line 109OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +89,21 @@89+ const executable = path.join(contentDir, platform === "win32" ? "t3.exe" : "t3");90+ for (const required of [executable, path.join(contentDir, "client/index.html")]) {91+ if (!(yield* fs.exists(required))) {92+ return yield* new CliArchiveSmokeError({93+ step: "checking the archive layout",94+ detail: `missing ${path.relative(contentDir, required)}`,95+ });96+ }97+ }98+99+ const version = yield* runExecutable(executable, ["--version"], contentDir);100+ if (version.exitCode !== 0 || !version.stdout.includes(input.expectVersion)) {101+ return yield* new CliArchiveSmokeError({102+ step: "running --version",103+ detail: `exit ${String(version.exitCode)}\n${version.stdout}${version.stderr}`,104+ });105+ }106+107+ // The preflight loads the persistence and terminal stacks, which is where108+ // native addons (sqlite, node-pty, msgpackr-extract) actually get resolved.109+ const preflight = yield* runExecutable(scripts/build-desktop-artifact.ts lines 2599 to 2599OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2596,4 +2596,4 @@25962596 });2597259725982598 export function resolveDesktopUpdateChannel(version: string): "latest" | "nightly" {2599- return /-nightly\.\d{8}\.\d+$/.test(version) ? "nightly" : "latest";2599+ return /-(?:nightly|preview)\.\d{8}\.\d+$/.test(version) ? "nightly" : "latest";
github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change
- .github/workflows/release.yml line 737OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -710,3 +728,10 @@710728711729 vp run dist:desktop:artifact "${args[@]}"712730731+ # The single-executable is built with a Node that supports --build-sea732+ # (25.7+); the repo itself stays on the engines.node version.733+ - name: Build CLI single-executable734+ shell: bash735+ env:736+ VP_NODE_VERSION: "26"737+ run: vp run --filter t3 build:exe
- scripts/build-cli-archive.ts lines 379 to 388OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +368,21 @@368+ readonly arch: BuildArch;369+ readonly version: string;370+ readonly outputDir: string;371+ readonly resourceMonitorDir: Option.Option<string>;372+}) {373+ const fs = yield* FileSystem.FileSystem;374+ const path = yield* Path.Path;375+ const repoRoot = yield* RepoRoot;376+ const serverDir = path.join(repoRoot, "apps/server");377+ const executableName = input.platform === "win" ? "t3.exe" : "t3";378+ // tsdown suffixes cross-built executables with their target (t3-darwin-x64);379+ // a host build is plain t3. Prefer the exact target when both exist.380+ const targetKey = `${input.platform === "mac" ? "darwin" : input.platform}-${input.arch}`;381+ const targetExecutable = path.join(382+ serverDir,383+ "dist-exe",384+ `t3-${targetKey}${input.platform === "win" ? ".exe" : ""}`,385+ );386+ const builtExecutable = (yield* fs.exists(targetExecutable))387+ ? targetExecutable388+ : path.join(serverDir, "dist-exe", executableName);apps/server/vite.config.ts lines 43 to 43OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -24,7 +24,20 @@24-const cliBuildChannel = packageJson.version.includes("-nightly.") ? "nightly" : "latest";24+const cliBuildChannel = /^[^-+]+-(?:nightly|preview)\./.test(packageJson.version)25+ ? "nightly"26+ : "latest";25272628 // `build:exe` wraps the same bundle in a Node single-executable. tsdown's exe2729 // step refuses multi-chunk output and counts the sourcemap as a chunk, and the2830 // executable needs a host Node that supports `--build-sea` (25.7+), so this is2931 // a separate mode rather than a second entry in the default build.3032 const packExecutable = process.env.T3CODE_PACK_EXE === "1";33+// `<platform>-<arch>` in nodejs.org naming (darwin-x64, linux-arm64, win-x64).34+// When set, tsdown injects the bundle into a downloaded Node of that target35+// instead of the host Node, which is how the arm64 macOS runner produces the36+// x64 archive. Cross-building is safe because the code cache is off.37+const packExecutableTarget = process.env.T3CODE_PACK_EXE_TARGET?.trim();38+const packExecutableTargets = packExecutableTarget39+ ? [40+ {41+ platform: packExecutableTarget.split("-")[0] as "darwin" | "linux" | "win",42+ arch: packExecutableTarget.split("-")[1] as "arm64" | "x64",43+ nodeVersion: process.versions.node,
- @@ -712,0 +798,21 @@798+ AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}799+ AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}800+ AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}801+ AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}802+ run: |803+ set -euo pipefail804+ if [[ "${{ matrix.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then805+ key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"806+ printf '%s' "$APPLE_API_KEY" > "$key_path"807+ export APPLE_API_KEY="$key_path"808+ fi809+ node scripts/build-cli-archive.ts \810+ --platform "${{ matrix.platform }}" \811+ --arch "${{ matrix.arch }}" \812+ --version "${{ needs.preflight.outputs.version }}" \813+ --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \814+ --output-dir release-cli815+816+ - name: Smoke-test CLI archive817+ shell: bash818+ run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ needs.preflight.outputs.version }}"@@ -21,4 +21,6 @@2121 export { shouldBundleCliDependency };22222323 const repoEnv = loadRepoEnv();24-const cliBuildChannel = packageJson.version.includes("-nightly.") ? "nightly" : "latest";24+const cliBuildChannel = /^[^-+]+-(?:nightly|preview)\./.test(packageJson.version)25+ ? "nightly"26+ : "latest";@@ -0,0 +137,21 @@137+ const output = yield* Effect.forkScoped(138+ Effect.all([collect(server.stdout), collect(server.stderr)]),139+ );140+ const httpClient = yield* HttpClient.HttpClient;141+ // A request that connects while the server is still initializing can hang,142+ // so each probe gets its own deadline, like the SSH readiness probe.143+ const probe = httpClient.execute(HttpClientRequest.get(`http://127.0.0.1:${String(port)}/`)).pipe(144+ Effect.map((response) => response.status === 200),145+ Effect.timeout(Duration.seconds(2)),146+ Effect.orElseSucceed(() => false),147+ );148+ const pollUntilReady = Effect.gen(function* () {149+ while (!(yield* probe)) {150+ yield* Effect.sleep(Duration.millis(250));151+ }152+ return true;153+ });154+ const ready = yield* pollUntilReady.pipe(155+ Effect.timeout(Duration.seconds(30)),156+ Effect.orElseSucceed(() => false),157+ );
- apps/server/vite.config.ts lines 46 to 47OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -25,6 +27,21 @@25272628 // `build:exe` wraps the same bundle in a Node single-executable. tsdown's exe2729 // step refuses multi-chunk output and counts the sourcemap as a chunk, and the2830 // executable needs a host Node that supports `--build-sea` (25.7+), so this is2931 // a separate mode rather than a second entry in the default build.3032 const packExecutable = process.env.T3CODE_PACK_EXE === "1";33+// `<platform>-<arch>` in nodejs.org naming (darwin-x64, linux-arm64, win-x64).34+// When set, tsdown injects the bundle into a downloaded Node of that target35+// instead of the host Node, which is how the arm64 macOS runner produces the36+// x64 archive. Cross-building is safe because the code cache is off.37+//38+// The Node inside the executable is pinned here rather than taken from the39+// build host, so every archive of a release embeds the same runtime no matter40+// which Node happens to run the build.41+const SEA_NODE_VERSION = "26.8.2";42+const packExecutableTarget = process.env.T3CODE_PACK_EXE_TARGET?.trim();43+const packExecutableTargets = packExecutableTarget44+ ? [45+ {46+ platform: packExecutableTarget.split("-")[0] as "darwin" | "linux" | "win",47+ arch: packExecutableTarget.split("-")[1] as "arm64" | "x64",
- apps/server/vite.config.ts line 51OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -29,2 +31,21 @@2931 // a separate mode rather than a second entry in the default build.3032 const packExecutable = process.env.T3CODE_PACK_EXE === "1";33+// `<platform>-<arch>` in nodejs.org naming (darwin-x64, linux-arm64, win-x64).34+// When set, tsdown injects the bundle into a downloaded Node of that target35+// instead of the host Node, which is how the arm64 macOS runner produces the36+// x64 archive. Cross-building is safe because the code cache is off.37+//38+// The Node inside the executable is pinned here rather than taken from the39+// build host, so every archive of a release embeds the same runtime no matter40+// which Node happens to run the build.41+const SEA_NODE_VERSION = "26.8.2";42+const SEA_TARGETS = {43+ "darwin-arm64": { platform: "darwin", arch: "arm64" },44+ "darwin-x64": { platform: "darwin", arch: "x64" },45+ "linux-arm64": { platform: "linux", arch: "arm64" },46+ "linux-x64": { platform: "linux", arch: "x64" },47+ "win-arm64": { platform: "win", arch: "arm64" },48+ "win-x64": { platform: "win", arch: "x64" },49+} as const;50+const packExecutableTarget = process.env.T3CODE_PACK_EXE_TARGET?.trim();51+if (packExecutableTarget && !(packExecutableTarget in SEA_TARGETS)) {
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- .github/workflows/release.yml line 748OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -710,3 +729,20 @@710729711730 vp run dist:desktop:artifact "${args[@]}"712731732+ # The single-executable is built with a Node that supports --build-sea733+ # (25.7+); the repo itself stays on the engines.node version.734+ # The macOS x64 archive is cross-built on the arm64 runner: tsdown735+ # downloads the x64 Node and injects the bundle into it.736+ - name: Build CLI single-executable737+ shell: bash738+ env:739+ # The exact version, not a major: vp downloads it from nodejs.org/dist on740+ # the runner, and only exact versions have a dist directory. Keep in741+ # step with SEA_NODE_VERSION in apps/server/vite.config.ts.742+ VP_NODE_VERSION: "26.8.2"743+ run: |744+ case "${{ matrix.platform }}" in745+ mac) target="darwin-${{ matrix.arch }}" ;;746+ *) target="${{ matrix.platform }}-${{ matrix.arch }}" ;;747+ esac748+ node apps/server/scripts/cli.ts build-exe --target "$target" --verbose
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- @@ -0,0 +443,21 @@443+ const serverDir = path.join(repoRoot, "apps/server");444+ const executableName = input.platform === "win" ? "t3.exe" : "t3";445+ // tsdown suffixes cross-built executables with their target (t3-darwin-x64);446+ // a host build is plain t3. Prefer the exact target when both exist.447+ const targetKey = `${input.platform === "mac" ? "darwin" : input.platform}-${input.arch}`;448+ const targetExecutable = path.join(449+ serverDir,450+ "dist-exe",451+ `t3-${targetKey}${input.platform === "win" ? ".exe" : ""}`,452+ );453+ // The unsuffixed host build is only a valid stand-in when it was built for454+ // this platform and architecture; otherwise a missing target must fail.455+ const hostPlatform = yield* HostProcessPlatform;456+ const hostKey = `${hostPlatform === "win32" ? "win" : hostPlatform}-${yield* HostProcessArchitecture}`;457+ const builtExecutable = (yield* fs.exists(targetExecutable))458+ ? targetExecutable459+ : targetKey === hostKey460+ ? path.join(serverDir, "dist-exe", executableName)461+ : targetExecutable;462+ const webClient = path.join(serverDir, "dist/client");463+ const resourceMonitorDir = Option.getOrElse(input.resourceMonitorDir, () =>
- @@ -0,0 +466,21 @@466+467+ yield* requireInput(468+ builtExecutable,469+ `Run \`node apps/server/scripts/cli.ts build-exe --target ${targetKey}\` first.`,470+ );471+ yield* requireInput(path.join(webClient, "index.html"), "Run `vp run --filter t3 build` first.");472+ yield* requireInput(473+ resourceMonitorDir,474+ "Build the resource monitor or pass --resource-monitor-dir.",475+ );476+477+ const stem = cliArchiveStem(input.version, input.platform, input.arch);478+ const stageRoot = yield* fs.makeTempDirectoryScoped({ prefix: "t3-cli-archive-" });479+ const contentDir = path.join(stageRoot, stem);480+ yield* fs.makeDirectory(contentDir, { recursive: true });481+482+ yield* Effect.log(`[cli-archive] Staging ${stem}...`);483+ yield* fs.copyFile(builtExecutable, path.join(contentDir, executableName));484+ yield* stageWebClient(webClient, path.join(contentDir, "client"));485+ yield* fs.copy(resourceMonitorDir, path.join(contentDir, "resource-monitor"));486+ yield* stageRuntimeExternals({
juliusmarminge merged thiseb8f6f4
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
d6d034f· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.