Open History to see the last commit
1name: Release desktop build
2
3# One desktop platform/arch build, called once per target from release.yml so
4# each target is its own job with its own `needs`. The JS bundle (server, web
5# client, Electron main) comes from the `js-bundle` artifact that build_bundle
6# produced; this job only packages it, builds the native helpers, and, where
7# `cli_archive` is set, the self-contained CLI archive for its platform.
8
9on:
10 workflow_call:
11 secrets:
12 CSC_LINK:
13 required: false
14 CSC_KEY_PASSWORD:
15 required: false
16 APPLE_API_KEY:
17 required: false
18 APPLE_API_KEY_ID:
19 required: false
20 APPLE_API_ISSUER:
21 required: false
22 MACOS_PROVISIONING_PROFILE:
23 required: false
24 AZURE_TENANT_ID:
25 required: false
26 AZURE_CLIENT_ID:
27 required: false
28 AZURE_CLIENT_SECRET:
29 required: false
30 AZURE_TRUSTED_SIGNING_ENDPOINT:
31 required: false
32 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME:
33 required: false
34 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME:
35 required: false
36 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME:
37 required: false
38 inputs:
39 label:
40 required: true
41 type: string
42 runner:
43 required: true
44 type: string
45 platform:
46 required: true
47 type: string
48 target:
49 required: true
50 type: string
51 arch:
52 required: true
53 type: string
54 rust_target:
55 required: true
56 type: string
57 resource_key:
58 required: true
59 type: string
60 # Whether the job also builds the self-contained CLI archive for its own
61 # platform/arch, on this runner, and smoke-tests it here. Every archive
62 # is built on hardware of its own architecture.
63 cli_archive:
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
77 ref:
78 required: true
79 type: string
80 release_channel:
81 required: true
82 type: string
83 # Whether a `relay-client-tracing-config` artifact from the production
84 # relay state is expected. PR previews carry no tracing config.
85 relay_client_tracing:
86 required: false
87 default: true
88 type: boolean
89 clerk_publishable_key:
90 required: true
91 type: string
92 clerk_jwt_template:
93 required: true
94 type: string
95 clerk_cli_oauth_client_id:
96 required: true
97 type: string
98 relay_url:
99 required: true
100 type: string
101
102# electron-builder leaves the default arch (x64) out of the unpacked app's
103# directory name.
104env:
105 UNPACKED_DIR: ${{ inputs.platform }}-${{ inputs.arch != 'x64' && format('{0}-', inputs.arch) || '' }}unpacked
106
107permissions:
108 # Windows builds read this run's artifact list to wait for the Linux CLI archive.
109 actions: read
110 contents: read
111
112jobs:
113 build:
114 name: Build ${{ inputs.label }}
115 runs-on: ${{ inputs.runner }}
116 # Windows waits for the Linux CLI archive inside its own budget (see
117 # "Wait for Linux CLI archive"), so it gets that wait on top of the usual 30.
118 timeout-minutes: ${{ inputs.platform == 'win' && 70 || 30 }}
119 env:
120 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ inputs.clerk_publishable_key }}
121 T3CODE_CLERK_JWT_TEMPLATE: ${{ inputs.clerk_jwt_template }}
122 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ inputs.clerk_cli_oauth_client_id }}
123 T3CODE_RELAY_URL: ${{ inputs.relay_url }}
124 steps:
125 # This repository is public, so Git needs no credentials. checkout's
126 # credential cleanup runs submodule foreach even with submodules disabled,
127 # which fails on the orphaned gitlinks in our vendored .repos tree.
128 # checkout.workers=0 writes the files on every core. Alternating both ways
129 # in one job on the Windows runners, it wrote the files about 10s faster
130 # (about 40% on arm64).
131 - name: Checkout
132 shell: bash
133 env:
134 CHECKOUT_REF: ${{ inputs.ref }}
135 GIT_TERMINAL_PROMPT: "0"
136 run: |
137 set -euo pipefail
138 git init .
139 git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
140 git fetch --no-tags --depth=1 origin "$CHECKOUT_REF"
141 git sparse-checkout set --no-cone '/*' '!/.repos/'
142 git -c checkout.workers=0 checkout --detach FETCH_HEAD
143
144 - name: Setup Vite+
145 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
146 with:
147 node-version-file: package.json
148 cache: true
149 run-install: false
150
151 # pnpm checks the lockfile and policy before reusing this result. A missing
152 # artifact leaves the cache empty, so installation runs the checks again.
153 - name: Download dependency verification
154 continue-on-error: true
155 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
156 with:
157 name: release-dependency-verification
158 path: ${{ runner.temp }}/pnpm-metadata
159
160 - name: Install desktop dependencies
161 env:
162 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
163 run: vp install --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
164
165 - name: Cache resource monitor
166 id: resource_monitor_cache
167 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
168 with:
169 path: native/resource-monitor/target/${{ inputs.rust_target }}/release/t3-resource-monitor${{ inputs.platform == 'win' && '.exe' || '' }}
170 key: resource-monitor-${{ inputs.rust_target }}-${{ hashFiles('native/resource-monitor/Cargo.lock', 'native/resource-monitor/Cargo.toml', 'native/resource-monitor/src/**') }}
171
172 - name: Cache Linux capture helpers
173 if: inputs.platform == 'linux'
174 id: capture_helper_cache
175 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
176 with:
177 path: |
178 native/kde-snap-shot/target/${{ inputs.rust_target }}/release/t3-kde-snap-shot
179 native/hyprland-snap-shot/target/${{ inputs.rust_target }}/release/t3-hyprland-snap-shot
180 key: linux-capture-helpers-${{ inputs.rust_target }}-${{ hashFiles('native/kde-snap-shot/Cargo.lock', 'native/kde-snap-shot/Cargo.toml', 'native/kde-snap-shot/src/**', 'native/hyprland-snap-shot/Cargo.lock', 'native/hyprland-snap-shot/Cargo.toml', 'native/hyprland-snap-shot/src/**', 'native/hyprland-snap-shot/protocols/**') }}
181
182 - name: Setup Rust
183 if: steps.resource_monitor_cache.outputs.cache-hit != 'true' || (inputs.platform == 'linux' && steps.capture_helper_cache.outputs.cache-hit != 'true')
184 uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
185 with:
186 toolchain: stable
187 targets: ${{ inputs.rust_target }}
188
189 - name: Download relay client tracing config
190 if: inputs.relay_client_tracing
191 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
192 with:
193 name: relay-client-tracing-config
194 path: ${{ runner.temp }}/relay-client-tracing
195
196 - name: Load relay client tracing config
197 if: inputs.relay_client_tracing
198 shell: bash
199 run: |
200 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
201 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
202 echo "::add-mask::$tracing_token"
203 cat "$config_path" >> "$GITHUB_ENV"
204
205 - name: Align package versions to release version
206 run: node scripts/update-release-package-versions.ts "${{ inputs.version }}"
207
208 # The artifact root is `apps/` (upload-artifact keeps the least common
209 # ancestor of its paths), so extracting into `apps` restores
210 # apps/server/dist and apps/desktop/dist-electron at their build paths.
211 - name: Download JS bundle
212 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
213 with:
214 name: js-bundle
215 path: apps
216
217 - name: Install cargo-xwin
218 if: inputs.platform == 'win' && steps.resource_monitor_cache.outputs.cache-hit != 'true'
219 uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2
220 with:
221 tool: cargo-xwin@0.23.1
222
223 # Built here rather than inside the desktop build so the CLI archive,
224 # which bundles the same binary, can be built and uploaded first.
225 - name: Build resource monitor
226 if: steps.resource_monitor_cache.outputs.cache-hit != 'true'
227 shell: bash
228 run: cargo ${{ inputs.platform == 'win' && 'xwin build' || 'build' }} --locked --release --manifest-path native/resource-monitor/Cargo.toml --target "${{ inputs.rust_target }}"
229
230 # Off Windows, scripts/lib/windows-jsign.ts signs through jsign instead of
231 # the TrustedSigning PowerShell module.
232 - name: Install jsign
233 if: inputs.platform == 'win'
234 shell: bash
235 run: |
236 set -euo pipefail
237 dir="$RUNNER_TEMP/jsign"
238 mkdir -p "$dir"
239 curl -fsSL --retry 3 -o "$dir/jsign.jar" https://github.com/ebourg/jsign/releases/download/7.6/jsign-7.6.jar
240 echo "6cf58aa080e7ff82656f320cff8d4a3bff30408df8766806dcba3740dd839fa5 $dir/jsign.jar" | sha256sum -c -
241 printf '#!/bin/sh\nexec java -jar "%s" "$@"\n' "$dir/jsign.jar" > "$dir/jsign"
242 chmod +x "$dir/jsign"
243 echo "T3CODE_JSIGN=$dir/jsign" >> "$GITHUB_ENV"
244
245 # The desktop build applies the same branding to apps/server/dist/client
246 # (resolveDesktopWebAssetBrand in scripts/build-desktop-artifact.ts); the
247 # CLI archive below ships that client and is now built first.
248 - name: Apply web client branding
249 if: inputs.cli_archive
250 shell: bash
251 run: |
252 brand=production
253 if [[ "${{ inputs.version }}" =~ -nightly\.[0-9]{8}\.[0-9]+$ ]]; then brand=nightly; fi
254 node scripts/apply-web-brand-assets.ts "$brand" apps/server/dist/client
255
256 # The single-executable is built with a Node that supports --build-sea
257 # (25.7+); the repo itself stays on the engines.node version. A native
258 # build injects into the runner's own Node; a Windows target downloads its
259 # node.exe.
260 - name: Build CLI single-executable
261 if: inputs.cli_archive
262 shell: bash
263 env:
264 # The exact version, not a major: vp downloads it from nodejs.org/dist on
265 # the runner, and only exact versions have a dist directory. Keep in
266 # step with SEA_NODE_VERSION in apps/server/vite.config.ts.
267 VP_NODE_VERSION: "26.8.2"
268 # The executable bundles the server again, so it needs the same stamp
269 # as release.yml's JS bundle.
270 T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && inputs.release_channel || 'dev' }}
271 run: node apps/server/scripts/cli.ts build-exe --verbose ${{ inputs.platform == 'win' && format('--target win-{0}', inputs.arch) || '' }}
272
273 - name: Import macOS signing certificate for the CLI archive
274 if: inputs.cli_archive && inputs.platform == 'mac'
275 shell: bash
276 env:
277 CSC_LINK: ${{ secrets.CSC_LINK }}
278 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
279 run: |
280 set -euo pipefail
281 if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" ]]; then
282 echo "macOS CLI signing disabled (missing CSC_LINK); the archive is signed ad hoc."
283 exit 0
284 fi
285 keychain="$RUNNER_TEMP/t3-cli-signing.keychain-db"
286 keychain_password="$(openssl rand -hex 16)"
287 cert_path="$RUNNER_TEMP/t3-cli-signing.p12"
288 printf '%s' "$CSC_LINK" | base64 --decode > "$cert_path"
289 security create-keychain -p "$keychain_password" "$keychain"
290 security set-keychain-settings -lut 21600 "$keychain"
291 security unlock-keychain -p "$keychain_password" "$keychain"
292 security import "$cert_path" -k "$keychain" -P "$CSC_KEY_PASSWORD" -T /usr/bin/codesign
293 security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" >/dev/null
294 security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
295 identity="$(security find-identity -v -p codesigning "$keychain" | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -n 1)"
296 if [[ -z "$identity" ]]; then
297 echo "No Developer ID Application identity found in CSC_LINK." >&2
298 exit 1
299 fi
300 echo "::add-mask::$keychain_password"
301 echo "T3CODE_CLI_MAC_SIGN_IDENTITY=$identity" >> "$GITHUB_ENV"
302 echo "macOS CLI signing enabled."
303
304 - name: Stage resource monitor for the CLI archive
305 if: inputs.cli_archive
306 shell: bash
307 run: |
308 set -euo pipefail
309 binary_name="t3-resource-monitor"
310 if [[ "${{ inputs.platform }}" == "win" ]]; then
311 binary_name="${binary_name}.exe"
312 fi
313 target_dir="$RUNNER_TEMP/cli-resource-monitor/${{ inputs.resource_key }}"
314 mkdir -p "$target_dir"
315 cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
316
317 - name: Build CLI archive
318 if: inputs.cli_archive
319 shell: bash
320 env:
321 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
322 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
323 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
324 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
325 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
326 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
327 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
328 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
329 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
330 run: |
331 set -euo pipefail
332 if [[ "${{ inputs.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then
333 key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"
334 printf '%s' "$APPLE_API_KEY" > "$key_path"
335 export APPLE_API_KEY="$key_path"
336 fi
337 node scripts/build-cli-archive.ts \
338 --platform "${{ inputs.platform }}" \
339 --arch "${{ inputs.arch }}" \
340 --version "${{ inputs.version }}" \
341 --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \
342 --output-dir release-cli
343
344 - name: Smoke-test CLI archive
345 if: inputs.cli_archive && inputs.verify_runner == ''
346 shell: bash
347 run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ inputs.version }}"
348
349 - name: Upload CLI archive
350 if: inputs.cli_archive
351 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
352 with:
353 name: cli-${{ inputs.platform }}-${{ inputs.arch }}
354 path: release-cli/*
355 if-no-files-found: error
356
357 - uses: ./.github/actions/setup-apt-mirrors
358 if: inputs.platform == 'linux'
359
360 - name: Install Linux desktop build libraries
361 if: inputs.platform == 'linux'
362 shell: bash
363 run: |
364 sudo apt-get update
365 sudo apt-get install -y libsecret-1-dev pkg-config
366 if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
367 sudo apt-get install -y imagemagick
368 fi
369
370 if command -v magick >/dev/null 2>&1; then
371 magick -version
372 else
373 convert -version
374 fi
375
376 # The WSL backend runs the Linux CLI archive inside the distro, so the
377 # Windows desktop embeds the same-arch archive the release attaches.
378 # This job starts alongside that Linux job instead of after it, and the
379 # Linux job uploads the archive partway through, so the wait is placed
380 # after all other setup. It stops early if the Linux job ended without
381 # uploading the archive.
382 - name: Wait for Linux CLI archive
383 if: inputs.platform == 'win'
384 shell: pwsh
385 timeout-minutes: 40
386 env:
387 GITHUB_TOKEN: ${{ github.token }}
388 ARTIFACT: cli-linux-${{ inputs.arch }}
389 LINUX_JOB: Build Linux ${{ inputs.arch }}
390 run: |
391 $headers = @{ Authorization = "Bearer $env:GITHUB_TOKEN"; Accept = "application/vnd.github+json" }
392 $run = "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
393 function Test-Archive {
394 (Invoke-RestMethod -Headers $headers -Uri "$run/artifacts?name=$env:ARTIFACT").total_count -gt 0
395 }
396 $missingSince = $null
397 while ($true) {
398 try {
399 if (Test-Archive) {
400 Write-Host "$env:ARTIFACT is ready."
401 exit 0
402 }
403 $jobs = Invoke-RestMethod -Headers $headers -Uri "$run/attempts/$env:GITHUB_RUN_ATTEMPT/jobs?per_page=100"
404 $linux = $jobs.jobs | Where-Object { $_.name.EndsWith($env:LINUX_JOB) } | Select-Object -First 1
405 if (-not $linux) {
406 # Both jobs start together, so a Linux job still missing after a
407 # few minutes means a renamed or skipped job, not a slow one.
408 if (-not $missingSince) {
409 $missingSince = Get-Date
410 } elseif (((Get-Date) - $missingSince).TotalMinutes -ge 5) {
411 Write-Host "::error::No job named '$env:LINUX_JOB' in this run, so $env:ARTIFACT will not arrive."
412 exit 1
413 }
414 } elseif ($linux.conclusion) {
415 # The upload may have landed between the two requests above.
416 if (Test-Archive) {
417 Write-Host "$env:ARTIFACT is ready."
418 exit 0
419 }
420 Write-Host "::error::$env:LINUX_JOB ended ($($linux.conclusion)) without uploading $env:ARTIFACT."
421 exit 1
422 }
423 } catch {
424 Write-Warning "Could not read this run's artifacts or jobs: $($_.Exception.Message)"
425 }
426 Write-Host "Waiting for $env:ARTIFACT..."
427 Start-Sleep -Seconds 10
428 }
429
430 - name: Download Linux CLI archive for WSL
431 if: inputs.platform == 'win'
432 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
433 with:
434 name: cli-linux-${{ inputs.arch }}
435 path: wsl-runtime
436
437 - name: Build desktop artifact
438 shell: bash
439 env:
440 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
441 T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
442 T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
443 CSC_LINK: ${{ secrets.CSC_LINK }}
444 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
445 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
446 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
447 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
448 APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
449 MACOS_PROVISIONING_PROFILE: ${{ secrets.MACOS_PROVISIONING_PROFILE }}
450 T3CODE_CLERK_PASSKEY_RP_DOMAINS: ${{ vars.CLERK_PASSKEY_RP_DOMAINS }}
451 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
452 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
453 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
454 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
455 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
456 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
457 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
458 run: |
459 args=(
460 --platform "${{ inputs.platform }}"
461 --target "${{ inputs.target }}"
462 --arch "${{ inputs.arch }}"
463 --build-version "${{ inputs.version }}"
464 --skip-build
465 --verbose
466 )
467 if [[ -n "${{ inputs.verify_runner }}" ]]; then
468 args+=(--keep-stage)
469 fi
470
471 has_all() {
472 for value in "$@"; do
473 if [[ -z "$value" ]]; then
474 return 1
475 fi
476 done
477 return 0
478 }
479
480 if [[ "${{ inputs.platform }}" == "mac" ]]; then
481 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
482 if ! has_all "$APPLE_TEAM_ID" "$MACOS_PROVISIONING_PROFILE"; then
483 echo "macOS signing is configured, but APPLE_TEAM_ID or MACOS_PROVISIONING_PROFILE is missing." >&2
484 exit 1
485 fi
486
487 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
488 printf '%s' "$APPLE_API_KEY" > "$key_path"
489 export APPLE_API_KEY="$key_path"
490
491 profile_path="$RUNNER_TEMP/t3code.provisionprofile"
492 printf '%s' "$MACOS_PROVISIONING_PROFILE" | base64 -D > "$profile_path"
493 security cms -D -i "$profile_path" >/dev/null
494 export T3CODE_APPLE_TEAM_ID="$APPLE_TEAM_ID"
495 export T3CODE_MACOS_PROVISIONING_PROFILE="$profile_path"
496
497 echo "macOS signing enabled."
498 args+=(--signed)
499 else
500 echo "macOS signing disabled (missing one or more Apple signing secrets)."
501 fi
502 elif [[ "${{ inputs.platform }}" == "win" ]]; then
503 # Embed the Linux CLI archive built by the same-arch Linux job as
504 # the WSL runtime. Required for a working WSL backend on Windows.
505 args+=(--wsl-runtime "$GITHUB_WORKSPACE"/wsl-runtime/t3-*-linux-${{ inputs.arch }}.tar.gz)
506 if has_all \
507 "$AZURE_TENANT_ID" \
508 "$AZURE_CLIENT_ID" \
509 "$AZURE_CLIENT_SECRET" \
510 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
511 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
512 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
513 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
514 echo "Windows signing enabled (Azure Trusted Signing)."
515 args+=(--signed)
516 else
517 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
518 fi
519 else
520 echo "Signing disabled for ${{ inputs.platform }}."
521 fi
522
523 vp run dist:desktop:artifact "${args[@]}"
524
525 # The verify job runs what this host could not: the packaged natives and
526 # the CLI. Its scripts are bundled so that job needs no install.
527 - name: Stage verification inputs
528 if: inputs.verify_runner != ''
529 shell: bash
530 run: |
531 set -euo pipefail
532 mkdir -p verify
533 unpacked=$(ls -d "${TMPDIR:-/tmp}"/t3code-desktop-${{ inputs.platform }}-stage-*/app/dist/"$UNPACKED_DIR")
534 tar -C "$(dirname "$unpacked")" -cf verify/unpacked.tar "$(basename "$unpacked")"
535 esbuild=scripts/node_modules/.bin/esbuild
536 banner="import{createRequire as __cr}from'node:module';const require=__cr(import.meta.url);"
537 # build-desktop-artifact.ts's own import.meta.main guard must not run
538 # its CLI inside the verify bundle.
539 "$esbuild" scripts/verify-windows-desktop-artifact.ts --bundle --platform=node --format=esm \
540 --target=node24 --define:import.meta.main=false --banner:js="$banner" \
541 --outfile=verify/verify-windows-desktop-artifact.mjs
542 "$esbuild" scripts/smoke-cli-archive.ts --bundle --platform=node --format=esm \
543 --target=node24 --banner:js="$banner" --outfile=verify/smoke-cli-archive.mjs
544
545 - name: Upload verification inputs
546 if: inputs.verify_runner != ''
547 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
548 with:
549 name: verify-${{ inputs.platform }}-${{ inputs.arch }}
550 path: verify/*
551 if-no-files-found: error
552 retention-days: 1
553 compression-level: 1
554
555 - name: Collect release assets
556 shell: bash
557 run: |
558 set -euo pipefail
559 mkdir -p release-publish
560
561 shopt -s nullglob
562 patterns=(
563 "release/*.dmg"
564 "release/*.zip"
565 "release/*.AppImage"
566 "release/*.deb"
567 "release/*.exe"
568 )
569 # Preview builds have no publish config, so electron-builder writes
570 # no feed manifest for them, but it still emits blockmaps beside the
571 # installers. Neither belongs on a release no updater may follow.
572 if [[ "${{ inputs.release_channel }}" != "preview" ]]; then
573 patterns+=("release/*.blockmap" "release/*.yml")
574 fi
575 for pattern in "${patterns[@]}"; do
576 for file in $pattern; do
577 cp "$file" release-publish/
578 done
579 done
580
581 if [[ "${{ inputs.platform }}" == "mac" && "${{ inputs.arch }}" != "arm64" ]]; then
582 shopt -s nullglob
583 for manifest in release-publish/*-mac.yml; do
584 mv "$manifest" "${manifest%.yml}-${{ inputs.arch }}.yml"
585 done
586 fi
587
588 # Windows updater metadata is channel-specific (for example
589 # "latest.yml" or "nightly.yml") and carries no arch, so the x64 and
590 # arm64 jobs would upload the same name. Suffix each per-arch copy;
591 # the release job merges them back into one manifest per channel.
592 # builder-debug.yml is electron-builder's config dump, not a feed.
593 if [[ "${{ inputs.platform }}" == "win" ]]; then
594 for manifest in release-publish/*.yml; do
595 [[ "$manifest" == */builder-debug.yml ]] && continue
596 mv "$manifest" "${manifest%.yml}-win-${{ inputs.arch }}.yml"
597 done
598 fi
599
600 - name: Collect resource monitor
601 shell: bash
602 run: |
603 set -euo pipefail
604 binary_name="t3-resource-monitor"
605 if [[ "${{ inputs.platform }}" == "win" ]]; then
606 binary_name="${binary_name}.exe"
607 fi
608 source_path="native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}"
609 target_dir="resource-monitor-publish/${{ inputs.resource_key }}"
610 mkdir -p "$target_dir"
611 cp "$source_path" "$target_dir/$binary_name"
612
613 - name: Upload build artifacts
614 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
615 with:
616 name: desktop-${{ inputs.platform }}-${{ inputs.arch }}
617 path: release-publish/*
618 if-no-files-found: error
619
620 - name: Upload resource monitor
621 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
622 with:
623 name: resource-monitor-${{ inputs.resource_key }}
624 path: resource-monitor-publish/${{ inputs.resource_key }}/*
625 if-no-files-found: error
626
627 verify:
628 name: Verify
629 needs: [build]
630 if: inputs.verify_runner != ''
631 runs-on: ${{ inputs.verify_runner }}
632 timeout-minutes: 15
633 steps:
634 - name: Download verification inputs
635 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
636 with:
637 name: verify-${{ inputs.platform }}-${{ inputs.arch }}
638 path: verify
639
640 - name: Download CLI archive
641 if: inputs.cli_archive
642 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
643 with:
644 name: cli-${{ inputs.platform }}-${{ inputs.arch }}
645 path: release-cli
646
647 - name: Verify packaged natives
648 shell: bash
649 run: |
650 set -euo pipefail
651 tar -C verify -xf verify/unpacked.tar
652 node verify/verify-windows-desktop-artifact.mjs \
653 --app-dir "$(cygpath -w "$PWD/verify/$UNPACKED_DIR")" \
654 --arch "${{ inputs.arch }}" --build-version "${{ inputs.version }}" --verbose
655
656 - name: Smoke-test CLI archive
657 if: inputs.cli_archive
658 shell: bash
659 run: node verify/smoke-cli-archive.mjs --archive release-cli/* --expect-version "${{ inputs.version }}"
660
661 # cargo-xwin links this binary on Linux, and nothing else runs it before users do.
662 # Node rather than pwsh: PowerShell on Windows ARM crashes intermittently
663 # (https://github.com/dotnet/runtime/issues/131636), which is why this
664 # target stopped building on Windows.
665 - name: Smoke-test resource monitor
666 shell: bash
667 env:
668 MONITOR: verify/${{ env.UNPACKED_DIR }}/resources/resource-monitor/t3-resource-monitor.exe
669 EXPECTED_ARCH: ${{ inputs.arch == 'arm64' && 'aarch64' || 'x86_64' }}
670 run: |
671 node --input-type=module <<'EOF'
672 import { spawn } from "node:child_process";
673 const monitor = spawn(process.env.MONITOR, { stdio: ["pipe", "pipe", "inherit"] });
674 monitor.stdout.setEncoding("utf8");
675 let output = "";
676 const exited = new Promise((resolve) => monitor.on("close", resolve));
677 const hello = await new Promise((resolve, reject) => {
678 monitor.on("error", reject);
679 monitor.on("close", () => reject(new Error(`Resource monitor exited before hello: ${output}`)));
680 monitor.stdout.on("data", (chunk) => {
681 output += chunk;
682 const end = output.indexOf("\n");
683 if (end !== -1) resolve(JSON.parse(output.slice(0, end)));
684 });
685 });
686 if (hello.type !== "hello" || hello.arch !== process.env.EXPECTED_ARCH) {
687 throw new Error(`Unexpected hello: ${JSON.stringify(hello)}`);
688 }
689 const send = (message) => monitor.stdin.write(`${JSON.stringify({ version: hello.version, ...message })}\n`);
690 send({ type: "configure", rootPid: process.pid, sampleIntervalMs: 1000 });
691 send({ type: "sampleNow", requestId: "verify" });
692 monitor.stdin.end();
693 const exitCode = await exited;
694 const sample = output
695 .split("\n")
696 .filter((line) => line.trim())
697 .map((line) => JSON.parse(line))
698 .find((message) => message.requestId === "verify");
699 if (exitCode !== 0 || sample?.type !== "snapshot" || !sample.processes.some((p) => p.pid === process.pid)) {
700 throw new Error(`Resource monitor exited ${exitCode} with: ${output}`);
701 }
702 console.log(`Resource monitor sampled ${sample.scannedProcessCount} processes.`);
703 EOF