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 22, 20:45 UTC
ci(release): Make Windows arm64 CI job 50% faster (#22428)
Jacob Hands committed
Oct 20, 2026 at 16:51 UTC
14b47ee1b83aa302cb8c5cc511b56da16f2bcbc2
16 files changed
+537
-181
.github/workflows/release-desktop.yml
+254
-148
@@ -64,6 +64,13 @@ on:
64
required: false
65
default: false
66
type: boolean
67
+ # A runner of the target's own platform and architecture, for a `runner`
68
+ # that cannot execute the target. The build job skips everything that
69
+ # runs the packaged binaries, and a second job runs it there.
70
+ verify_runner:
71
+ required: false
72
+ default: ""
73
+ type: string
74
version:
75
required: true
76
type: string
@@ -129,39 +136,6 @@ jobs:
136
git sparse-checkout set --no-cone '/*' '!/.repos/'
137
git -c checkout.workers=0 checkout --detach FETCH_HEAD
138
132
- # The runner's PowerShell 7.6/.NET 10 intermittently crashes during signing:
133
- # https://github.com/dotnet/runtime/issues/131636
134
- # Put the .NET 8 release first for both workflow shells and electron-builder.
135
- - name: Use PowerShell 7.4 for Windows ARM builds
136
- if: inputs.platform == 'win' && inputs.arch == 'arm64'
137
- shell: powershell
138
- run: |
139
- $ErrorActionPreference = "Stop"
140
- $ProgressPreference = "SilentlyContinue"
141
- $version = "7.4.20"
142
- $archive = Join-Path $env:RUNNER_TEMP "PowerShell-$version-win-arm64.zip"
143
- $installDir = Join-Path $env:RUNNER_TEMP "powershell-$version-arm64"
144
- Invoke-WebRequest -UseBasicParsing `
145
- -Uri "https://github.com/PowerShell/PowerShell/releases/download/v$version/PowerShell-$version-win-arm64.zip" `
146
- -OutFile $archive
147
- $expectedHash = "67eff749d5dae357501c95a3eec1dcd93f669824e3ca2b1d2adcdecdebf04f35"
148
- if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne $expectedHash) {
149
- throw "PowerShell archive checksum mismatch"
150
- }
151
- Expand-Archive -Path $archive -DestinationPath $installDir
152
- $installDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
153
- & "$installDir\pwsh.exe" -NoProfile -NonInteractive -Command '$PSVersionTable; [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture'
154
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
155
-
156
- - name: Verify Windows ARM PowerShell selection
157
- if: inputs.platform == 'win' && inputs.arch == 'arm64'
158
- shell: pwsh
159
- run: |
160
- $expectedPath = Join-Path $env:RUNNER_TEMP "powershell-7.4.20-arm64\pwsh.exe"
161
- if ((Get-Command pwsh.exe).Source -ne $expectedPath -or $PSVersionTable.PSVersion -ne [version]"7.4.20") {
162
- throw "Windows ARM builds must use the pinned PowerShell runtime"
163
- }
164
-
139
# Windows installs straight from the registry. There, linking the packages
140
# takes the time, not downloading them, so a ~700 MB package cache did not
141
# pay for its own restore. Across recent nightlies, restore plus install
@@ -172,7 +146,7 @@ jobs:
146
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
147
with:
148
node-version-file: package.json
175
- cache: ${{ inputs.platform != 'win' }}
149
+ cache: ${{ runner.os != 'Windows' }}
150
run-install: false
151
152
# pnpm checks the lockfile and policy before reusing this result. A missing
@@ -245,7 +219,7 @@ jobs:
219
# monitor, the desktop build's preflight skips its MSVC check, and node-pty
220
# ships prebuilt Windows binaries, so the 30-60s install is skipped too.
221
- name: Install Spectre-mitigated MSVC libs
248
- if: inputs.platform == 'win' && steps.resource_monitor_cache.outputs.cache-hit != 'true'
222
+ if: runner.os == 'Windows' && steps.resource_monitor_cache.outputs.cache-hit != 'true'
223
shell: pwsh
224
run: |
225
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
@@ -261,27 +235,21 @@ jobs:
235
exit $code
236
}
237
264
- - uses: ./.github/actions/setup-apt-mirrors
265
- if: inputs.platform == 'linux'
238
+ - name: Install cargo-xwin
239
+ if: runner.os != 'Windows' && inputs.platform == 'win' && steps.resource_monitor_cache.outputs.cache-hit != 'true'
240
+ uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2
241
+ with:
242
+ tool: cargo-xwin
243
267
- - name: Install Linux desktop build libraries
268
- if: inputs.platform == 'linux'
244
+ # Built here rather than inside the desktop build so the CLI archive,
245
+ # which bundles the same binary, can be built and uploaded first.
246
+ - name: Build resource monitor
247
+ if: steps.resource_monitor_cache.outputs.cache-hit != 'true'
248
shell: bash
270
- run: |
271
- sudo apt-get update
272
- sudo apt-get install -y libsecret-1-dev pkg-config
273
- if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
274
- sudo apt-get install -y imagemagick
275
- fi
276
-
277
- if command -v magick >/dev/null 2>&1; then
278
- magick -version
279
- else
280
- convert -version
281
- fi
249
+ run: cargo ${{ runner.os != 'Windows' && inputs.platform == 'win' && 'xwin build' || 'build' }} --locked --release --manifest-path native/resource-monitor/Cargo.toml --target "${{ inputs.rust_target }}"
250
251
- name: Prepare Azure Trusted Signing
284
- if: inputs.platform == 'win'
252
+ if: inputs.platform == 'win' && runner.os == 'Windows'
253
shell: pwsh
254
env:
255
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
@@ -342,6 +310,153 @@ jobs:
310
Select-Object -Unique
311
"PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
312
313
+ # Off Windows, scripts/lib/windows-jsign.ts signs through jsign instead of
314
+ # the TrustedSigning PowerShell module.
315
+ - name: Install jsign
316
+ if: inputs.platform == 'win' && runner.os != 'Windows'
317
+ shell: bash
318
+ run: |
319
+ set -euo pipefail
320
+ dir="$RUNNER_TEMP/jsign"
321
+ mkdir -p "$dir"
322
+ curl -fsSL --retry 3 -o "$dir/jsign.jar" https://github.com/ebourg/jsign/releases/download/7.6/jsign-7.6.jar
323
+ echo "6cf58aa080e7ff82656f320cff8d4a3bff30408df8766806dcba3740dd839fa5 $dir/jsign.jar" | sha256sum -c -
324
+ printf '#!/bin/sh\nexec java -jar "%s" "$@"\n' "$dir/jsign.jar" > "$dir/jsign"
325
+ chmod +x "$dir/jsign"
326
+ echo "T3CODE_JSIGN=$dir/jsign" >> "$GITHUB_ENV"
327
+
328
+ # The desktop build applies the same branding to apps/server/dist/client
329
+ # (resolveDesktopWebAssetBrand in scripts/build-desktop-artifact.ts); the
330
+ # CLI archive below ships that client and is now built first.
331
+ - name: Apply web client branding
332
+ if: inputs.cli_archive
333
+ shell: bash
334
+ run: |
335
+ brand=production
336
+ if [[ "${{ inputs.version }}" =~ -nightly\.[0-9]{8}\.[0-9]+$ ]]; then brand=nightly; fi
337
+ node scripts/apply-web-brand-assets.ts "$brand" apps/server/dist/client
338
+
339
+ # The single-executable is built with a Node that supports --build-sea
340
+ # (25.7+); the repo itself stays on the engines.node version. A native
341
+ # build injects into the runner's own Node: tsdown's cross-target download
342
+ # path runs `tar` on a drive-letter path on Windows, which GNU tar reads as
343
+ # a remote host. Off Windows, a Windows target downloads its node.exe.
344
+ - name: Build CLI single-executable
345
+ if: inputs.cli_archive
346
+ shell: bash
347
+ env:
348
+ # The exact version, not a major: vp downloads it from nodejs.org/dist on
349
+ # the runner, and only exact versions have a dist directory. Keep in
350
+ # step with SEA_NODE_VERSION in apps/server/vite.config.ts.
351
+ VP_NODE_VERSION: "26.8.2"
352
+ # The executable bundles the server again, so it needs the same stamp
353
+ # as release.yml's JS bundle.
354
+ T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && inputs.release_channel || 'dev' }}
355
+ run: node apps/server/scripts/cli.ts build-exe --verbose ${{ runner.os != 'Windows' && inputs.platform == 'win' && format('--target win-{0}', inputs.arch) || '' }}
356
+
357
+ - name: Import macOS signing certificate for the CLI archive
358
+ if: inputs.cli_archive && inputs.platform == 'mac'
359
+ shell: bash
360
+ env:
361
+ CSC_LINK: ${{ secrets.CSC_LINK }}
362
+ CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
363
+ run: |
364
+ set -euo pipefail
365
+ if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" ]]; then
366
+ echo "macOS CLI signing disabled (missing CSC_LINK); the archive is signed ad hoc."
367
+ exit 0
368
+ fi
369
+ keychain="$RUNNER_TEMP/t3-cli-signing.keychain-db"
370
+ keychain_password="$(openssl rand -hex 16)"
371
+ cert_path="$RUNNER_TEMP/t3-cli-signing.p12"
372
+ printf '%s' "$CSC_LINK" | base64 --decode > "$cert_path"
373
+ security create-keychain -p "$keychain_password" "$keychain"
374
+ security set-keychain-settings -lut 21600 "$keychain"
375
+ security unlock-keychain -p "$keychain_password" "$keychain"
376
+ security import "$cert_path" -k "$keychain" -P "$CSC_KEY_PASSWORD" -T /usr/bin/codesign
377
+ security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" >/dev/null
378
+ security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
379
+ identity="$(security find-identity -v -p codesigning "$keychain" | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -n 1)"
380
+ if [[ -z "$identity" ]]; then
381
+ echo "No Developer ID Application identity found in CSC_LINK." >&2
382
+ exit 1
383
+ fi
384
+ echo "::add-mask::$keychain_password"
385
+ echo "T3CODE_CLI_MAC_SIGN_IDENTITY=$identity" >> "$GITHUB_ENV"
386
+ echo "macOS CLI signing enabled."
387
+
388
+ - name: Stage resource monitor for the CLI archive
389
+ if: inputs.cli_archive
390
+ shell: bash
391
+ run: |
392
+ set -euo pipefail
393
+ binary_name="t3-resource-monitor"
394
+ if [[ "${{ inputs.platform }}" == "win" ]]; then
395
+ binary_name="${binary_name}.exe"
396
+ fi
397
+ target_dir="$RUNNER_TEMP/cli-resource-monitor/${{ inputs.resource_key }}"
398
+ mkdir -p "$target_dir"
399
+ cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
400
+
401
+ - name: Build CLI archive
402
+ if: inputs.cli_archive
403
+ shell: bash
404
+ env:
405
+ APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
406
+ APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
407
+ APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
408
+ AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
409
+ AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
410
+ AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
411
+ AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
412
+ AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
413
+ AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
414
+ run: |
415
+ set -euo pipefail
416
+ if [[ "${{ inputs.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then
417
+ key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"
418
+ printf '%s' "$APPLE_API_KEY" > "$key_path"
419
+ export APPLE_API_KEY="$key_path"
420
+ fi
421
+ node scripts/build-cli-archive.ts \
422
+ --platform "${{ inputs.platform }}" \
423
+ --arch "${{ inputs.arch }}" \
424
+ --version "${{ inputs.version }}" \
425
+ --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \
426
+ --output-dir release-cli
427
+
428
+ - name: Smoke-test CLI archive
429
+ if: inputs.cli_archive && inputs.verify_runner == ''
430
+ shell: bash
431
+ run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ inputs.version }}"
432
+
433
+ - name: Upload CLI archive
434
+ if: inputs.cli_archive
435
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
436
+ with:
437
+ name: cli-${{ inputs.platform }}-${{ inputs.arch }}
438
+ path: release-cli/*
439
+ if-no-files-found: error
440
+
441
+ - uses: ./.github/actions/setup-apt-mirrors
442
+ if: inputs.platform == 'linux'
443
+
444
+ - name: Install Linux desktop build libraries
445
+ if: inputs.platform == 'linux'
446
+ shell: bash
447
+ run: |
448
+ sudo apt-get update
449
+ sudo apt-get install -y libsecret-1-dev pkg-config
450
+ if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
451
+ sudo apt-get install -y imagemagick
452
+ fi
453
+
454
+ if command -v magick >/dev/null 2>&1; then
455
+ magick -version
456
+ else
457
+ convert -version
458
+ fi
459
+
460
# The WSL backend runs the Linux CLI archive inside the distro, so the
461
# Windows desktop embeds the same-arch archive the release attaches.
462
# This job starts alongside that Linux job instead of after it, and the
@@ -407,7 +522,7 @@ jobs:
522
shell: bash
523
env:
524
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
410
- T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: ${{ steps.resource_monitor_cache.outputs.cache-hit == 'true' }}
525
+ T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
526
T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
527
CSC_LINK: ${{ secrets.CSC_LINK }}
528
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
@@ -433,6 +548,9 @@ jobs:
548
--skip-build
549
--verbose
550
)
551
+ if [[ -n "${{ inputs.verify_runner }}" ]]; then
552
+ args+=(--keep-stage)
553
+ fi
554
555
has_all() {
556
for value in "$@"; do
@@ -488,107 +606,35 @@ jobs:
606
607
vp run dist:desktop:artifact "${args[@]}"
608
491
- # The single-executable is built with a Node that supports --build-sea
492
- # (25.7+); the repo itself stays on the engines.node version. It always
493
- # injects into the runner's own Node: tsdown's cross-target download path
494
- # runs `tar` on a drive-letter path on Windows, which GNU tar reads as a
495
- # remote host, and a cross-built macOS binary cannot be smoke-tested.
496
- - name: Build CLI single-executable
497
- if: inputs.cli_archive
498
- shell: bash
499
- env:
500
- # The exact version, not a major: vp downloads it from nodejs.org/dist on
501
- # the runner, and only exact versions have a dist directory. Keep in
502
- # step with SEA_NODE_VERSION in apps/server/vite.config.ts.
503
- VP_NODE_VERSION: "26.8.2"
504
- # The executable bundles the server again, so it needs the same stamp
505
- # as release.yml's JS bundle.
506
- T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && inputs.release_channel || 'dev' }}
507
- run: node apps/server/scripts/cli.ts build-exe --verbose
508
-
509
- - name: Import macOS signing certificate for the CLI archive
510
- if: inputs.cli_archive && inputs.platform == 'mac'
511
- shell: bash
512
- env:
513
- CSC_LINK: ${{ secrets.CSC_LINK }}
514
- CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
515
- run: |
516
- set -euo pipefail
517
- if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" ]]; then
518
- echo "macOS CLI signing disabled (missing CSC_LINK); the archive is signed ad hoc."
519
- exit 0
520
- fi
521
- keychain="$RUNNER_TEMP/t3-cli-signing.keychain-db"
522
- keychain_password="$(openssl rand -hex 16)"
523
- cert_path="$RUNNER_TEMP/t3-cli-signing.p12"
524
- printf '%s' "$CSC_LINK" | base64 --decode > "$cert_path"
525
- security create-keychain -p "$keychain_password" "$keychain"
526
- security set-keychain-settings -lut 21600 "$keychain"
527
- security unlock-keychain -p "$keychain_password" "$keychain"
528
- security import "$cert_path" -k "$keychain" -P "$CSC_KEY_PASSWORD" -T /usr/bin/codesign
529
- security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" >/dev/null
530
- security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
531
- identity="$(security find-identity -v -p codesigning "$keychain" | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -n 1)"
532
- if [[ -z "$identity" ]]; then
533
- echo "No Developer ID Application identity found in CSC_LINK." >&2
534
- exit 1
535
- fi
536
- echo "::add-mask::$keychain_password"
537
- echo "T3CODE_CLI_MAC_SIGN_IDENTITY=$identity" >> "$GITHUB_ENV"
538
- echo "macOS CLI signing enabled."
539
-
540
- - name: Stage resource monitor for the CLI archive
541
- if: inputs.cli_archive
609
+ # The verify job runs what this host could not: the packaged natives and
610
+ # the CLI. Its scripts are bundled so that job needs no install.
611
+ - name: Stage verification inputs
612
+ if: inputs.verify_runner != ''
613
shell: bash
614
run: |
615
set -euo pipefail
545
- binary_name="t3-resource-monitor"
546
- if [[ "${{ inputs.platform }}" == "win" ]]; then
547
- binary_name="${binary_name}.exe"
548
- fi
549
- target_dir="$RUNNER_TEMP/cli-resource-monitor/${{ inputs.resource_key }}"
550
- mkdir -p "$target_dir"
551
- cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
552
-
553
- - name: Build CLI archive
554
- if: inputs.cli_archive
555
- shell: bash
556
- env:
557
- APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
558
- APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
559
- APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
560
- AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
561
- AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
562
- AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
563
- AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
564
- AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
565
- AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
566
- run: |
567
- set -euo pipefail
568
- if [[ "${{ inputs.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then
569
- key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"
570
- printf '%s' "$APPLE_API_KEY" > "$key_path"
571
- export APPLE_API_KEY="$key_path"
572
- fi
573
- node scripts/build-cli-archive.ts \
574
- --platform "${{ inputs.platform }}" \
575
- --arch "${{ inputs.arch }}" \
576
- --version "${{ inputs.version }}" \
577
- --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \
578
- --output-dir release-cli
579
-
580
- - name: Smoke-test CLI archive
581
- if: inputs.cli_archive
582
- shell: bash
583
- run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ inputs.version }}"
584
-
585
- - name: Upload CLI archive
586
- if: inputs.cli_archive
616
+ mkdir -p verify
617
+ unpacked=$(ls -d "${TMPDIR:-/tmp}"/t3code-desktop-${{ inputs.platform }}-stage-*/app/dist/${{ inputs.platform }}-${{ inputs.arch }}-unpacked)
618
+ tar -C "$(dirname "$unpacked")" -cf verify/unpacked.tar "$(basename "$unpacked")"
619
+ esbuild=scripts/node_modules/.bin/esbuild
620
+ banner="import{createRequire as __cr}from'node:module';const require=__cr(import.meta.url);"
621
+ # build-desktop-artifact.ts's own import.meta.main guard must not run
622
+ # its CLI inside the verify bundle.
623
+ "$esbuild" scripts/verify-windows-desktop-artifact.ts --bundle --platform=node --format=esm \
624
+ --target=node24 --define:import.meta.main=false --banner:js="$banner" \
625
+ --outfile=verify/verify-windows-desktop-artifact.mjs
626
+ "$esbuild" scripts/smoke-cli-archive.ts --bundle --platform=node --format=esm \
627
+ --target=node24 --banner:js="$banner" --outfile=verify/smoke-cli-archive.mjs
628
+
629
+ - name: Upload verification inputs
630
+ if: inputs.verify_runner != ''
631
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
632
with:
589
- name: cli-${{ inputs.platform }}-${{ inputs.arch }}
590
- path: release-cli/*
633
+ name: verify-${{ inputs.platform }}-${{ inputs.arch }}
634
+ path: verify/*
635
if-no-files-found: error
636
+ retention-days: 1
637
+ compression-level: 1
638
639
- name: Collect release assets
640
shell: bash
@@ -661,3 +707,63 @@ jobs:
707
name: resource-monitor-${{ inputs.resource_key }}
708
path: resource-monitor-publish/${{ inputs.resource_key }}/*
709
if-no-files-found: error
710
+
711
+ verify:
712
+ name: Verify
713
+ needs: [build]
714
+ if: inputs.verify_runner != ''
715
+ runs-on: ${{ inputs.verify_runner }}
716
+ timeout-minutes: 15
717
+ steps:
718
+ - name: Download verification inputs
719
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
720
+ with:
721
+ name: verify-${{ inputs.platform }}-${{ inputs.arch }}
722
+ path: verify
723
+
724
+ - name: Download CLI archive
725
+ if: inputs.cli_archive
726
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
727
+ with:
728
+ name: cli-${{ inputs.platform }}-${{ inputs.arch }}
729
+ path: release-cli
730
+
731
+ - name: Verify packaged natives
732
+ shell: bash
733
+ run: |
734
+ set -euo pipefail
735
+ tar -C verify -xf verify/unpacked.tar
736
+ node verify/verify-windows-desktop-artifact.mjs \
737
+ --app-dir "$(cygpath -w "$PWD/verify/${{ inputs.platform }}-${{ inputs.arch }}-unpacked")" \
738
+ --arch "${{ inputs.arch }}" --build-version "${{ inputs.version }}" --verbose
739
+
740
+ - name: Smoke-test CLI archive
741
+ if: inputs.cli_archive
742
+ shell: bash
743
+ run: node verify/smoke-cli-archive.mjs --archive release-cli/* --expect-version "${{ inputs.version }}"
744
+
745
+ # cargo-xwin links this binary on Linux, and nothing else runs it before users do.
746
+ - name: Smoke-test resource monitor
747
+ shell: pwsh
748
+ run: |
749
+ $startInfo = [System.Diagnostics.ProcessStartInfo]::new(
750
+ "verify\${{ inputs.platform }}-${{ inputs.arch }}-unpacked\resources\resource-monitor\t3-resource-monitor.exe")
751
+ $startInfo.UseShellExecute = $false
752
+ $startInfo.RedirectStandardInput = $true
753
+ $startInfo.RedirectStandardOutput = $true
754
+ $monitor = [System.Diagnostics.Process]::Start($startInfo)
755
+ $hello = $monitor.StandardOutput.ReadLine() | ConvertFrom-Json
756
+ if ($hello.type -ne "hello" -or $hello.arch -ne "${{ inputs.arch == 'arm64' && 'aarch64' || 'x86_64' }}") {
757
+ throw "Unexpected hello: $($hello | ConvertTo-Json -Compress)"
758
+ }
759
+ $monitor.StandardInput.WriteLine((@{ version = $hello.version; type = "configure"; rootPid = $PID; sampleIntervalMs = 1000 } | ConvertTo-Json -Compress))
760
+ $monitor.StandardInput.WriteLine((@{ version = $hello.version; type = "sampleNow"; requestId = "verify" } | ConvertTo-Json -Compress))
761
+ $monitor.StandardInput.Close()
762
+ $output = $monitor.StandardOutput.ReadToEnd()
763
+ $monitor.WaitForExit()
764
+ $sample = $output -split "`n" | Where-Object { $_.Trim() } | ForEach-Object { $_ | ConvertFrom-Json } |
765
+ Where-Object { $_.requestId -eq "verify" }
766
+ if ($monitor.ExitCode -ne 0 -or $sample.type -ne "snapshot" -or -not ($sample.processes | Where-Object { $_.pid -eq $PID })) {
767
+ throw "Resource monitor exited $($monitor.ExitCode) with: $output"
768
+ }
769
+ "Resource monitor sampled $($sample.scannedProcessCount) processes."
.github/workflows/release.yml
+4
-1
@@ -659,6 +659,8 @@ jobs:
659
resource_key: win32-x64
660
cli_archive: true
661
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.
664
desktop_win_arm64:
665
name: Desktop Windows arm64
666
needs: [preflight, relay_public_config, build_bundle]
@@ -674,7 +676,8 @@ jobs:
676
clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
677
relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
678
label: Windows arm64
677
- runner: windows-11-arm
679
+ runner: blacksmith-16vcpu-ubuntu-2404
680
+ verify_runner: windows-11-arm
681
platform: win
682
target: nsis
683
arch: arm64
docs/operations/release.md
+3
-3
@@ -31,7 +31,7 @@ the version.
31
- Runs lint, typecheck, and tests alongside artifact builds. Publishing waits for every check.
32
- Reads the shared production T3 Connect relay URL and Clerk client configuration before packaging clients.
33
- 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:
35
- macOS `arm64` DMG
36
- macOS `x64` DMG
37
- 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.
42
- Nightly runs are always GitHub prereleases and never marked latest.
43
- 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.
44
- 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.
46
- 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`.
47
- 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`.
48
- 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.
50
- 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.
51
- stable releases publish npm dist-tag `latest`
52
- nightly releases publish npm dist-tag `nightly`
knip.jsonc
+9
-2
@@ -18,8 +18,15 @@
18
},
19
"scripts": {
20
// 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"],
30
// The `t3` npm package's files: copied into the package, never imported.
31
"ignore": ["npm-launcher/**"],
32
},
patches/app-builder-lib@26.16.1.patch
new
+15
@@ -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
+8
-4
@@ -179,6 +179,7 @@ patchedDependencies:
179
'@react-native-menu/menu@2.0.0': a4866ecfcd44f318043de839d20110c17e14909004900f002ffe12050376f2ba
180
'@react-navigation/native-stack@7.21.0': caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e
181
alchemy@2.0.0-beta.80: bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd
182
+ app-builder-lib@26.16.1: a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3
183
dbus-next@0.10.2: cfff57561b0ee59b5addb3b2e6c6f20906e967507a530ab67e8db8108e520ba4
184
expo-audio@58.0.9: 2c2f8c73a23d48804c8b537b8cd73c25eb331aa47d82eaa481c6766cb81e5add
185
expo-modules-core@58.0.22: f0b0fd100550ed76e5c25b4d13eb7c9ff62825f8f197c53edf7bf447c50c9fb7
@@ -1962,6 +1963,9 @@ importers:
1963
'@types/pngjs':
1964
specifier: 6.0.5
1965
version: 6.0.5
1966
+ esbuild:
1967
+ specifier: 0.28.2
1968
+ version: 0.28.2
1969
typescript:
1970
specifier: 'catalog:'
1971
version: 7.0.2
@@ -18181,7 +18185,7 @@ snapshots:
18185
anynum@1.0.1:
18186
optional: true
18187
18184
- app-builder-lib@26.16.1(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1):
18188
+ app-builder-lib@26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1):
18189
dependencies:
18190
'@electron/asar': 3.4.1
18191
'@electron/fuses': 1.8.0
@@ -19234,7 +19238,7 @@ snapshots:
19238
19239
dmg-builder@26.16.1(electron-builder-squirrel-windows@26.16.1):
19240
dependencies:
19237
- app-builder-lib: 26.16.1(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)
19241
+ app-builder-lib: 26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)
19242
builder-util: 26.16.0
19243
fs-extra: 10.1.0
19244
js-yaml: 4.3.2
@@ -19326,7 +19330,7 @@ snapshots:
19330
19331
electron-builder-squirrel-windows@26.16.1(dmg-builder@26.16.1):
19332
dependencies:
19329
- app-builder-lib: 26.16.1(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)
19333
+ app-builder-lib: 26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)
19334
builder-util: 26.16.0
19335
electron-winstaller: 5.4.0
19336
transitivePeerDependencies:
@@ -19335,7 +19339,7 @@ snapshots:
19339
19340
electron-builder@26.16.1(electron-builder-squirrel-windows@26.16.1):
19341
dependencies:
19338
- app-builder-lib: 26.16.1(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)
19342
+ app-builder-lib: 26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)
19343
builder-util: 26.16.0
19344
builder-util-runtime: 9.7.0
19345
chalk: 4.1.2
pnpm-workspace.yaml
+1
@@ -357,6 +357,7 @@ patchedDependencies:
357
# Android: Maven-resolved gradle plugins (expo-widgets) have no sourceDir; without this
358
# skip, the fingerprint silently drops every Expo native module and OTAs reach stale binaries.
359
"@expo/fingerprint@0.21.5": patches/@expo__fingerprint@0.21.5.patch
360
+ app-builder-lib@26.16.1: patches/app-builder-lib@26.16.1.patch
361
362
peerDependencyRules:
363
allowAny:
scripts/build-cli-archive.ts
+15
-6
@@ -30,6 +30,8 @@ import {
30
STAGE_INSTALL_ARGS,
31
} from "./build-desktop-artifact.ts";
32
import { selectCliRuntimeExternalDependencies } from "./lib/cli-external-packages.ts";
33
+import { signWithJsign } from "./lib/windows-jsign.ts";
34
+import { windowsSystemTar } from "./lib/windows-tar.ts";
35
import { resolveCatalogDependencies } from "./lib/resolve-catalog.ts";
36
37
const BuildPlatform = Schema.Literals(["mac", "linux", "win"]);
@@ -95,11 +97,6 @@ export function cliArchiveFileName(version: string, platform: BuildPlatform, arc
97
return `${cliArchiveStem(version, platform, arch)}.${platform === "win" ? "zip" : "tar.gz"}`;
98
}
99
98
-export function windowsSystemTar(): string {
99
- const systemRoot = process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows";
100
- return `${systemRoot}\\System32\\tar.exe`;
101
-}
102
-
100
const runCommand = Effect.fn("runCommand")(function* (
101
command: ChildProcess.Command,
102
label: string,
@@ -411,6 +408,11 @@ const signWindowsExecutable = Effect.fn("signWindowsExecutable")(function* (
408
return;
409
}
410
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
+ }
416
const quote = (value: string) => `'${value.replaceAll("'", "''")}'`;
417
const script = [
418
"$ErrorActionPreference = 'Stop';",
@@ -507,7 +509,14 @@ const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
509
cliArchiveFileName(input.version, input.platform, input.arch),
510
);
511
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") {
520
// Windows ships bsdtar, which writes zip natively. Name it by path: under
521
// the Git Bash shell CI uses, a bare `tar` is GNU tar, which neither
522
// writes zip nor accepts a drive-letter path.
scripts/build-desktop-artifact.test.ts
+64
-6
@@ -83,6 +83,7 @@ import {
83
LinuxBrowserSecretHostError,
84
stageBrowserSecret,
85
validateWindowsPackagedPayload,
86
+ verifyPackagedBundleIsSelfContained,
87
WindowsPrimaryNativeProbeError,
88
WindowsDesktopBuildPrerequisitesMissingError,
89
WindowsPackagedPayloadValidationError,
@@ -2063,21 +2064,44 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
2064
it.effect("rejects a sidecar whose extracted server bundle cannot resolve", () =>
2065
Effect.scoped(
2066
Effect.gen(function* () {
2067
+ const path = yield* Path.Path;
2068
const fixture = yield* makeWindowsPayloadFixture({
2069
copyUnpackedNatives: true,
2070
serverEntrySource: 'import "t3code-deliberately-missing-package";\n',
2071
});
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,
2075
}).pipe(Effect.flip);
2076
2077
assert.instanceOf(error, BundleNotSelfContainedError);
2078
assert.include(error.output, "t3code-deliberately-missing-package");
2079
}),
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
+ ),
2105
);
2106
2107
it.effect("preserves both Linux icon resize failures with structural context", () => {
@@ -2438,6 +2462,40 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
2462
}).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
2463
);
2464
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
+
2499
it("stages the resource monitor as an external executable resource", () => {
2500
assert.deepStrictEqual(DESKTOP_EXTRA_RESOURCES, [
2501
{
scripts/build-desktop-artifact.ts
+44
-9
@@ -2247,7 +2247,7 @@ export const copyDirectoryPreservingSymlinks = Effect.fn("copyDirectoryPreservin
2247
},
2248
);
2249
2250
-const verifyPackagedBundleIsSelfContained = Effect.fn("verifyPackagedBundleIsSelfContained")(
2250
+export const verifyPackagedBundleIsSelfContained = Effect.fn("verifyPackagedBundleIsSelfContained")(
2251
function* (input: { readonly asarPath: string; readonly verbose: boolean }) {
2252
const fs = yield* FileSystem.FileSystem;
2253
const path = yield* Path.Path;
@@ -3017,8 +3017,16 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
3017
// packaged executable with Electron's stock icon.
3018
signAndEditExecutable: true,
3019
};
3020
- if (signed) {
3020
+ if (signed && (yield* HostProcess.Platform) === "win32") {
3021
winConfig.azureSignOptions = yield* AzureTrustedSigningOptionsConfig;
3022
+ } else if (signed) {
3023
+ const path = yield* Path.Path;
3024
+ const { publisherName } = yield* AzureTrustedSigningOptionsConfig;
3025
+ winConfig.signtoolOptions = {
3026
+ sign: yield* path.fromFileUrl(new URL("./lib/windows-jsign.ts", import.meta.url)),
3027
+ signingHashAlgorithms: ["sha256"],
3028
+ publisherName: [publisherName],
3029
+ };
3030
}
3031
buildConfig.win = winConfig;
3032
}
@@ -3345,6 +3353,32 @@ export const verifyWindowsPrimaryFffNativeLoad = Effect.fn(
3353
);
3354
});
3355
3356
+/**
3357
+ * The fff probe needs a host of the target's platform and architecture; the
3358
+ * bundle self-check needs a Windows host. A cross build defers both to
3359
+ * scripts/verify-windows-desktop-artifact.ts.
3360
+ */
3361
+export const verifyWindowsPackagedRuntime = Effect.fn(
3362
+ "desktopArtifact.verifyWindowsPackagedRuntime",
3363
+)(function* (input: {
3364
+ readonly packagedAppDir: string;
3365
+ readonly appExecutableName: string;
3366
+ readonly targetArch: typeof BuildArch.Type;
3367
+ readonly verbose: boolean;
3368
+}) {
3369
+ const path = yield* Path.Path;
3370
+ const asarPath = path.join(input.packagedAppDir, "resources", WINDOWS_SERVER_ASAR_RESOURCE);
3371
+ yield* verifyWindowsPrimaryFffNativeLoad({ ...input, asarPath });
3372
+ const hostPlatform = yield* HostProcess.Platform;
3373
+ if (hostPlatform !== "win32") {
3374
+ yield* Effect.log(
3375
+ `[desktop-artifact] Skipped the bundle self-check on a ${hostPlatform} host.`,
3376
+ );
3377
+ return;
3378
+ }
3379
+ yield* verifyPackagedBundleIsSelfContained({ asarPath, verbose: input.verbose });
3380
+});
3381
+
3382
export const validateWindowsPackagedPayload = Effect.fn(
3383
"desktopArtifact.validateWindowsPackagedPayload",
3384
)(function* (input: {
@@ -3558,19 +3592,13 @@ export const validateWindowsPackagedPayload = Effect.fn(
3592
});
3593
}
3594
3561
- yield* verifyWindowsPrimaryFffNativeLoad({
3595
+ yield* verifyWindowsPackagedRuntime({
3596
packagedAppDir,
3563
- asarPath,
3597
appExecutableName: input.appExecutableName,
3598
targetArch: input.targetArch,
3599
verbose: input.verbose ?? false,
3600
});
3601
3569
- yield* verifyPackagedBundleIsSelfContained({
3570
- asarPath,
3571
- verbose: input.verbose ?? false,
3572
- });
3573
-
3602
yield* Effect.log(
3603
`[desktop-artifact] Validated Windows payload (${String(fileCount)} files, ${String(unpackedFiles.length)} sidecar natives).`,
3604
);
@@ -3993,6 +4021,13 @@ const buildDesktopArtifactUnlocked = Effect.fn("buildDesktopArtifactUnlocked")(f
4021
// takes seconds on a many-core runner instead of about two minutes.
4022
buildEnv.XZ_DEFAULTS = "-T0";
4023
}
4024
+ if (options.platform === "win") {
4025
+ // Windows signs only through Azure Trusted Signing. Off Windows,
4026
+ // electron-builder's signtool manager would read CSC_LINK (the macOS
4027
+ // certificate) as a Windows certificate.
4028
+ delete buildEnv.CSC_LINK;
4029
+ delete buildEnv.CSC_KEY_PASSWORD;
4030
+ }
4031
if (!options.signed) {
4032
buildEnv.CSC_IDENTITY_AUTO_DISCOVERY = "false";
4033
delete buildEnv.CSC_LINK;
scripts/build-npm-launcher.ts
+1
-1
@@ -26,7 +26,7 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
26
import { fromJsonStringPretty } from "@t3tools/shared/schemaJson";
27
import serverPackageJson from "../apps/server/package.json" with { type: "json" };
28
29
-import { windowsSystemTar } from "./build-cli-archive.ts";
29
+import { windowsSystemTar } from "./lib/windows-tar.ts";
30
31
export const NPM_LAUNCHER_PACKAGE_NAME = "t3";
32
scripts/lib/windows-jsign.ts
new
+65
@@ -0,0 +1,65 @@
1
+// Azure Trusted Signing from a non-Windows host. The Windows-only path is
2
+// electron-builder's azureSignOptions (PowerShell + signtool.exe); this one is
3
+// electron-builder's `win.signtoolOptions.sign` hook and the CLI archive's
4
+// signer. jsign reads AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET
5
+// itself when no --storepass is given.
6
+
7
+import * as NodeServices from "@effect/platform-node/NodeServices";
8
+import * as Config from "effect/Config";
9
+import * as Effect from "effect/Effect";
10
+import * as Schema from "effect/Schema";
11
+import { ChildProcess, ChildProcessSpawner } from "effect/process";
12
+
13
+export class JsignFailedError extends Schema.TaggedError<JsignFailedError>()("JsignFailedError", {
14
+ file: Schema.String,
15
+ exitCode: Schema.Number,
16
+}) {
17
+ override get message() {
18
+ return `jsign exited with code ${String(this.exitCode)} signing ${this.file}.`;
19
+ }
20
+}
21
+
22
+export const signWithJsign = Effect.fn("signWithJsign")(function* (file: string) {
23
+ const { jsign, endpoint, account, profile } = yield* Config.all({
24
+ jsign: Config.String("T3CODE_JSIGN").pipe(Config.withDefault("jsign")),
25
+ endpoint: Config.String("AZURE_TRUSTED_SIGNING_ENDPOINT"),
26
+ account: Config.String("AZURE_TRUSTED_SIGNING_ACCOUNT_NAME"),
27
+ profile: Config.String("AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME"),
28
+ });
29
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
30
+ const child = yield* spawner.spawn(
31
+ ChildProcess.make(
32
+ jsign,
33
+ [
34
+ "--storetype",
35
+ "TRUSTEDSIGNING",
36
+ "--keystore",
37
+ new URL(endpoint).host,
38
+ "--alias",
39
+ `${account}/${profile}`,
40
+ "--alg",
41
+ "SHA-256",
42
+ "--tsaurl",
43
+ "http://timestamp.acs.microsoft.com",
44
+ "--tsmode",
45
+ "RFC3161",
46
+ // jsign appends a nested signature by default; signtool replaces.
47
+ "--replace",
48
+ file,
49
+ ],
50
+ { stdout: "inherit", stderr: "inherit" },
51
+ ),
52
+ );
53
+ const exitCode = Number(yield* child.exitCode);
54
+ if (exitCode !== 0) {
55
+ return yield* new JsignFailedError({ file, exitCode });
56
+ }
57
+});
58
+
59
+export default function sign(configuration: { readonly path: string }): Promise<void> {
60
+ return signWithJsign(configuration.path).pipe(
61
+ Effect.scoped,
62
+ Effect.provide(NodeServices.layer),
63
+ Effect.runPromise,
64
+ );
65
+}
scripts/lib/windows-tar.ts
new
+4
@@ -0,0 +1,4 @@
1
+export function windowsSystemTar(): string {
2
+ const systemRoot = process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows";
3
+ return `${systemRoot}\\System32\\tar.exe`;
4
+}
scripts/package.json
+1
@@ -21,6 +21,7 @@
21
"@effect/vitest": "catalog:",
22
"@types/plist": "catalog:",
23
"@types/pngjs": "6.0.5",
24
+ "esbuild": "0.28.2",
25
"typescript": "catalog:",
26
"typescript-legacy": "npm:typescript@~6.0.3",
27
"vite-plus": "catalog:"
scripts/smoke-cli-archive.ts
+1
-1
@@ -16,7 +16,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
16
17
import * as NetService from "@t3tools/shared/Net";
18
import * as HostProcess from "@t3tools/shared/HostProcess";
19
-import { windowsSystemTar } from "./build-cli-archive.ts";
19
+import { windowsSystemTar } from "./lib/windows-tar.ts";
20
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
21
22
export class CliArchiveSmokeError extends Schema.TaggedError<CliArchiveSmokeError>()(
scripts/verify-windows-desktop-artifact.ts
new
+48
@@ -0,0 +1,48 @@
1
+#!/usr/bin/env node
2
+
3
+// Runs the native-load probes a cross-built Windows desktop artifact skipped,
4
+// on a host of the target's architecture.
5
+
6
+import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
7
+import * as NodeServices from "@effect/platform-node/NodeServices";
8
+import * as Effect from "effect/Effect";
9
+import * as Layer from "effect/Layer";
10
+import * as Logger from "effect/Logger";
11
+import { Command, Flag } from "effect/cli";
12
+
13
+import {
14
+ resolveDesktopProductName,
15
+ verifyWindowsPackagedRuntime,
16
+} from "./build-desktop-artifact.ts";
17
+
18
+const verifyWindowsDesktopArtifactCli = Command.make("verify-windows-desktop-artifact", {
19
+ appDir: Flag.String("app-dir").pipe(
20
+ Flag.withDescription("The electron-builder `win-<arch>-unpacked` directory."),
21
+ ),
22
+ arch: Flag.Literals("arch", ["arm64", "x64"] as const),
23
+ buildVersion: Flag.String("build-version").pipe(
24
+ Flag.withDescription("The artifact's build version."),
25
+ ),
26
+ verbose: Flag.Boolean("verbose").pipe(Flag.withDefault(false)),
27
+}).pipe(
28
+ Command.withDescription("Verify a Windows desktop artifact's packaged natives load."),
29
+ Command.withHandler(({ appDir, arch, buildVersion, verbose }) =>
30
+ Effect.gen(function* () {
31
+ yield* verifyWindowsPackagedRuntime({
32
+ packagedAppDir: appDir,
33
+ appExecutableName: `${resolveDesktopProductName(buildVersion)}.exe`,
34
+ targetArch: arch,
35
+ verbose,
36
+ });
37
+ yield* Effect.log(`[verify-windows-desktop-artifact] ${appDir} passed.`);
38
+ }),
39
+ ),
40
+);
41
+
42
+// No import.meta.main guard: CI bundles this file into one module together with
43
+// build-desktop-artifact.ts, whose own guard is defined false in that bundle.
44
+Command.run(verifyWindowsDesktopArtifactCli, { version: "0.0.0" }).pipe(
45
+ Effect.scoped,
46
+ Effect.provide(Layer.mergeAll(Logger.layer([Logger.consolePretty()]), NodeServices.layer)),
47
+ NodeRuntime.runMain,
48
+);