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