Skip to content

Commit 14b47ee

Browse files
authored
ci(release): Make Windows arm64 CI job 50% faster (pingdotgg#22428)
1 parent 2ebe280 commit 14b47ee

16 files changed

Lines changed: 537 additions & 181 deletions

‎.github/workflows/release-desktop.yml‎

Lines changed: 254 additions & 148 deletions
Large diffs are not rendered by default.

‎.github/workflows/release.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ jobs:
659659
resource_key: win32-x64
660660
cli_archive: true
661661

662+
# Windows arm64 runners have 4 vCPUs, and the packaging is mostly CPU-bound,
663+
# so the build runs on Linux and only the native checks run on arm64.
662664
desktop_win_arm64:
663665
name: Desktop Windows arm64
664666
needs: [preflight, relay_public_config, build_bundle]
@@ -674,7 +676,8 @@ jobs:
674676
clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
675677
relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
676678
label: Windows arm64
677-
runner: windows-11-arm
679+
runner: blacksmith-16vcpu-ubuntu-2404
680+
verify_runner: windows-11-arm
678681
platform: win
679682
target: nsis
680683
arch: arm64

‎docs/operations/release.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ the version.
3131
- Runs lint, typecheck, and tests alongside artifact builds. Publishing waits for every check.
3232
- Reads the shared production T3 Connect relay URL and Clerk client configuration before packaging clients.
3333
- Builds the platform-independent JS (server bundle, web client, Electron main) once in the `build_bundle` job and hands it to every platform job as the `js-bundle` artifact; the platform jobs only package it, so no runner rebuilds it.
34-
- Builds six desktop artifacts in parallel for both channels, each as its own job (`desktop_<platform>_<arch>`, one call of `release-desktop.yml`) on hardware of its own architecture, gated only on the bundle. The Windows jobs embed the same-arch Linux CLI archive as the WSL runtime and wait for that artifact partway through, not for the whole Linux job:
34+
- Builds six desktop artifacts in parallel for both channels, each as its own job (`desktop_<platform>_<arch>`, one call of `release-desktop.yml`), gated only on the bundle. Every target builds on hardware of its own architecture except Windows arm64: its runners have 4 vCPUs, so it builds and signs (with jsign) on a Linux runner, and a `windows-11-arm` job runs the packaged natives and the CLI archive (`verify_runner`). The Windows jobs embed the same-arch Linux CLI archive as the WSL runtime and wait for that artifact partway through, not for the whole Linux job:
3535
- macOS `arm64` DMG
3636
- macOS `x64` DMG
3737
- Linux `x64` and `arm64` AppImage and `.deb`, from one electron-builder run. The `.deb` updates in the app through electron-updater, which installs it with `dpkg`.
@@ -42,11 +42,11 @@ the version.
4242
- Nightly runs are always GitHub prereleases and never marked latest.
4343
- Automatically generated release notes are pinned to the previous tag in the same channel, so stable compares to the previous stable tag and nightly compares to the previous nightly tag.
4444
- Includes Electron auto-update metadata (for example `latest*.yml`, `nightly*.yml`, and `*.blockmap`) in release assets.
45-
- Builds a self-contained CLI archive per platform (`t3-<version>-<platform>-<arch>.tar.gz`, `.zip` on Windows) in the same job as that target's desktop artifact and attaches them to the GitHub Release with a `SHA256SUMS` file, on every channel, for five targets: macOS arm64, Linux x64 and arm64, Windows x64 and arm64. Every archive is built, signed, and smoke-tested on hardware of its own architecture. There is no macOS x64 archive: Node single-executables are unsupported on x64 macOS (the SEA docs list macOS as arm64 only) and the binary segfaults on start; the x64 desktop app is Electron and unaffected.
45+
- Builds a self-contained CLI archive per platform (`t3-<version>-<platform>-<arch>.tar.gz`, `.zip` on Windows) in the same job as that target's desktop artifact and attaches them to the GitHub Release with a `SHA256SUMS` file, on every channel, for five targets: macOS arm64, Linux x64 and arm64, Windows x64 and arm64. Every archive is smoke-tested on hardware of its own architecture, and every one but Windows arm64 is also built and signed there. There is no macOS x64 archive: Node single-executables are unsupported on x64 macOS (the SEA docs list macOS as arm64 only) and the binary segfaults on start; the x64 desktop app is Electron and unaffected.
4646
- The archive holds the server as a Node single-executable (`scripts/build-cli-archive.ts`), so unpacking it needs neither Node, npm, nor a compiler. It is the only form in which T3 Code manages a runtime: the desktop's SSH environments, the boot service, `t3 update`, and the install scripts all download and verify this archive against `SHA256SUMS`. The `t3` npm package exists for people who run `npx t3` or `npm install -g t3` themselves, and it downloads this same archive too; nothing in the product installs from npm. The `curl | sh` installers are `scripts/install.sh` and `scripts/install.ps1`; the marketing site copies them into its `public/` at build time (`apps/marketing/scripts/stage-install-scripts.mjs`) and serves them at `t3.codes/install.sh` and `/install.ps1`.
4747
- The executable is built with a Node that supports `--build-sea` (`VP_NODE_VERSION=26.8.2`, kept in step with `SEA_NODE_VERSION` in `apps/server/vite.config.ts`), while the repo stays on `engines.node`.
4848
- macOS archives are signed with the Developer ID certificate and notarized when the Apple secrets are present (ad hoc otherwise, which still runs from `curl`/`tar` installs). Windows executables use the same Azure Trusted Signing setup as the installer. Every native addon in the macOS archive is signed too, since the hardened runtime refuses unsigned libraries.
49-
- Each archive is extracted and executed on its build runner (`scripts/smoke-cli-archive.ts`) before it is uploaded.
49+
- Each archive is extracted and executed (`scripts/smoke-cli-archive.ts`) on its build runner, or on the `verify_runner` for Windows arm64.
5050
- After the GitHub Release is published, publishes the `t3` npm package with OIDC trusted publishing from the same workflow file. It is only a launcher (`scripts/npm-launcher/t3.mjs`): on first run it downloads its exact version's CLI archive from the GitHub Release, verifies it against `SHA256SUMS`, and unpacks it into `<T3 home>/runtime/versions/<version>`, the layout the install scripts and `t3 update` share. The executables are not on npm. They used to be, as `@t3code/t3-<platform>-<arch>` optional dependencies, but npm's publish-time scanning held those 80-250 MB packages back for up to an hour after the launcher was live, and every install in that window got a launcher with no executable. Those packages stay on npm at their old versions and get no new ones. Because the launcher reads from the release, `publish_cli` runs after `release`, never before.
5151
- stable releases publish npm dist-tag `latest`
5252
- nightly releases publish npm dist-tag `nightly`

‎knip.jsonc‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@
1818
},
1919
"scripts": {
2020
// Knip loads its preprocessor through a CLI option; native verification and
21-
// worktree setup (from t3.json) run directly.
22-
"entry": ["knip-schemas.ts", "mobile-native-client.ts", "setup-worktree.ts"],
21+
// worktree setup (from t3.json) run directly. release-desktop.yml bundles the
22+
// Windows verify script with esbuild through a path knip does not trace.
23+
"entry": [
24+
"knip-schemas.ts",
25+
"mobile-native-client.ts",
26+
"setup-worktree.ts",
27+
"verify-windows-desktop-artifact.ts",
28+
],
29+
"ignoreDependencies": ["esbuild"],
2330
// The `t3` npm package's files: copied into the package, never imported.
2431
"ignore": ["npm-launcher/**"],
2532
},

‎patches/[email protected]‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/out/targets/nsis/NsisTarget.js b/out/targets/nsis/NsisTarget.js
2+
index 8a3462b185b078a260483635e6d774e2ece6e269..105778c145ab63a26444179215c643a7f22148a0 100644
3+
--- a/out/targets/nsis/NsisTarget.js
4+
+++ b/out/targets/nsis/NsisTarget.js
5+
@@ -366,7 +366,9 @@ class NsisTarget extends core_1.Target {
6+
await this.executeMakensis(defines, commands, sharedHeader + (await this.computeFinalScript(script, false, archs)));
7+
// http://forums.winamp.com/showthread.php?p=3078545
8+
// TODO: remove workaround when wine is fully upgraded to 11
9+
- if ((0, macosVersion_1.isMacOsCatalina)()) {
10+
+ // T3 Code builds Windows installers on Linux without wine; read the
11+
+ // uninstaller out of the stub the way macOS hosts already do.
12+
+ if ((0, macosVersion_1.isMacOsCatalina)() || process.platform === "linux") {
13+
try {
14+
await nsisUtil_1.UninstallerReader.exec(installerPath, uninstallerPath);
15+
}

‎pnpm-lock.yaml‎

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ patchedDependencies:
357357
# Android: Maven-resolved gradle plugins (expo-widgets) have no sourceDir; without this
358358
# skip, the fingerprint silently drops every Expo native module and OTAs reach stale binaries.
359359
360+
360361

361362
peerDependencyRules:
362363
allowAny:

‎scripts/build-cli-archive.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
STAGE_INSTALL_ARGS,
3131
} from "./build-desktop-artifact.ts";
3232
import { selectCliRuntimeExternalDependencies } from "./lib/cli-external-packages.ts";
33+
import { signWithJsign } from "./lib/windows-jsign.ts";
34+
import { windowsSystemTar } from "./lib/windows-tar.ts";
3335
import { resolveCatalogDependencies } from "./lib/resolve-catalog.ts";
3436

3537
const BuildPlatform = Schema.Literals(["mac", "linux", "win"]);
@@ -95,11 +97,6 @@ export function cliArchiveFileName(version: string, platform: BuildPlatform, arc
9597
return `${cliArchiveStem(version, platform, arch)}.${platform === "win" ? "zip" : "tar.gz"}`;
9698
}
9799

98-
export function windowsSystemTar(): string {
99-
const systemRoot = process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows";
100-
return `${systemRoot}\\System32\\tar.exe`;
101-
}
102-
103100
const runCommand = Effect.fn("runCommand")(function* (
104101
command: ChildProcess.Command,
105102
label: string,
@@ -411,6 +408,11 @@ const signWindowsExecutable = Effect.fn("signWindowsExecutable")(function* (
411408
return;
412409
}
413410
yield* stripStaleAuthenticodeEntry(executablePath);
411+
if ((yield* HostProcess.Platform) !== "win32") {
412+
yield* signWithJsign(executablePath);
413+
yield* Effect.log("[cli-archive] Signed t3.exe (Azure Trusted Signing via jsign).");
414+
return;
415+
}
414416
const quote = (value: string) => `'${value.replaceAll("'", "''")}'`;
415417
const script = [
416418
"$ErrorActionPreference = 'Stop';",
@@ -507,7 +509,14 @@ const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
507509
cliArchiveFileName(input.version, input.platform, input.arch),
508510
);
509511
yield* fs.remove(archivePath, { force: true });
510-
if (input.platform === "win") {
512+
if (input.platform === "win" && hostPlatform !== "win32") {
513+
yield* runCommand(
514+
ChildProcess.make("zip", ["-q", "-r", "-X", path.resolve(archivePath), stem], {
515+
cwd: stageRoot,
516+
}),
517+
"zip",
518+
);
519+
} else if (input.platform === "win") {
511520
// Windows ships bsdtar, which writes zip natively. Name it by path: under
512521
// the Git Bash shell CI uses, a bare `tar` is GNU tar, which neither
513522
// writes zip nor accepts a drive-letter path.

‎scripts/build-desktop-artifact.test.ts‎

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import {
8383
LinuxBrowserSecretHostError,
8484
stageBrowserSecret,
8585
validateWindowsPackagedPayload,
86+
verifyPackagedBundleIsSelfContained,
8687
WindowsPrimaryNativeProbeError,
8788
WindowsDesktopBuildPrerequisitesMissingError,
8889
WindowsPackagedPayloadValidationError,
@@ -2063,21 +2064,44 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
20632064
it.effect("rejects a sidecar whose extracted server bundle cannot resolve", () =>
20642065
Effect.scoped(
20652066
Effect.gen(function* () {
2067+
const path = yield* Path.Path;
20662068
const fixture = yield* makeWindowsPayloadFixture({
20672069
copyUnpackedNatives: true,
20682070
serverEntrySource: 'import "t3code-deliberately-missing-package";\n',
20692071
});
2070-
const error = yield* validateWindowsPackagedPayload({
2071-
stageDistDir: fixture.stageDistDir,
2072-
appExecutableName: fixture.appExecutableName,
2073-
targetArch: "x64",
2074-
appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION,
2072+
const error = yield* verifyPackagedBundleIsSelfContained({
2073+
asarPath: path.join(fixture.packagedAppDir, "resources", WINDOWS_SERVER_ASAR_RESOURCE),
2074+
verbose: false,
20752075
}).pipe(Effect.flip);
20762076

20772077
assert.instanceOf(error, BundleNotSelfContainedError);
20782078
assert.include(error.output, "t3code-deliberately-missing-package");
20792079
}),
2080-
).pipe(Effect.provideService(HostProcess.Platform, "linux")),
2080+
),
2081+
);
2082+
2083+
it.effect("leaves the bundle self-check of a cross-built payload to the verify job", () =>
2084+
Effect.scoped(
2085+
Effect.gen(function* () {
2086+
const fixture = yield* makeWindowsPayloadFixture({
2087+
copyUnpackedNatives: true,
2088+
serverEntrySource: 'import "t3code-deliberately-missing-package";\n',
2089+
});
2090+
yield* validateWindowsPackagedPayload({
2091+
stageDistDir: fixture.stageDistDir,
2092+
appExecutableName: fixture.appExecutableName,
2093+
targetArch: "arm64",
2094+
appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION,
2095+
});
2096+
}),
2097+
).pipe(
2098+
Effect.provide(
2099+
Layer.mergeAll(
2100+
Layer.succeed(HostProcess.Platform, "linux"),
2101+
Layer.succeed(HostProcess.Architecture, "x64"),
2102+
),
2103+
),
2104+
),
20812105
);
20822106

20832107
it.effect("preserves both Linux icon resize failures with structural context", () => {
@@ -2438,6 +2462,40 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
24382462
}).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
24392463
);
24402464

2465+
it.effect("signs Windows builds with signtool on Windows and the jsign hook elsewhere", () =>
2466+
Effect.gen(function* () {
2467+
const signedWinConfig = (hostPlatform: string) =>
2468+
createBuildConfig("win", "nsis", "1.2.3", true, false, undefined, undefined).pipe(
2469+
Effect.map((config) => config.win as Record<string, unknown>),
2470+
Effect.provideService(HostProcess.Platform, hostPlatform),
2471+
);
2472+
2473+
const onWindows = yield* signedWinConfig("win32");
2474+
assert.equal((onWindows.azureSignOptions as Record<string, unknown>).publisherName, "T3");
2475+
assert.notProperty(onWindows, "signtoolOptions");
2476+
2477+
const onLinux = yield* signedWinConfig("linux");
2478+
assert.notProperty(onLinux, "azureSignOptions");
2479+
const signtoolOptions = onLinux.signtoolOptions as Record<string, unknown>;
2480+
assert.match(signtoolOptions.sign as string, /scripts[\\/]lib[\\/]windows-jsign\.ts$/);
2481+
assert.deepStrictEqual(signtoolOptions.signingHashAlgorithms, ["sha256"]);
2482+
assert.deepStrictEqual(signtoolOptions.publisherName, ["T3"]);
2483+
}).pipe(
2484+
Effect.provide(
2485+
ConfigProvider.layer(
2486+
ConfigProvider.fromEnv({
2487+
env: {
2488+
AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: "T3",
2489+
AZURE_TRUSTED_SIGNING_ENDPOINT: "https://eus.codesigning.azure.net/",
2490+
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: "profile",
2491+
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: "account",
2492+
},
2493+
}),
2494+
),
2495+
),
2496+
),
2497+
);
2498+
24412499
it("stages the resource monitor as an external executable resource", () => {
24422500
assert.deepStrictEqual(DESKTOP_EXTRA_RESOURCES, [
24432501
{

0 commit comments

Comments
 (0)