Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

release-desktop.yml

571 lines24.6 KB

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 version:
68 required: true
69 type: string
70 ref:
71 required: true
72 type: string
73 release_channel:
74 required: true
75 type: string
76 # Whether a `relay-client-tracing-config` artifact from the production
77 # relay state is expected. PR previews carry no tracing config.
78 relay_client_tracing:
79 required: false
80 default: true
81 type: boolean
82 clerk_publishable_key:
83 required: true
84 type: string
85 clerk_jwt_template:
86 required: true
87 type: string
88 clerk_cli_oauth_client_id:
89 required: true
90 type: string
91 relay_url:
92 required: true
93 type: string
94​
95permissions:
96 contents: read
97​
98jobs:
99 build:
100 name: Build ${{ inputs.label }}
101 runs-on: ${{ inputs.runner }}
102 timeout-minutes: 30
103 env:
104 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ inputs.clerk_publishable_key }}
105 T3CODE_CLERK_JWT_TEMPLATE: ${{ inputs.clerk_jwt_template }}
106 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ inputs.clerk_cli_oauth_client_id }}
107 T3CODE_RELAY_URL: ${{ inputs.relay_url }}
108 steps:
109 # This repository is public, so Git needs no credentials. checkout's
110 # credential cleanup runs submodule foreach even with submodules disabled,
111 # which fails on the orphaned gitlinks in our vendored .repos tree.
112 # checkout.workers=0 writes the files on every core. Alternating both ways
113 # in one job on the Windows runners, it wrote the files about 10s faster
114 # (about 40% on arm64).
115 - name: Checkout
116 shell: bash
117 env:
118 CHECKOUT_REF: ${{ inputs.ref }}
119 GIT_TERMINAL_PROMPT: "0"
120 run: |
121 set -euo pipefail
122 git init .
123 git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
124 git fetch --no-tags --depth=1 origin "$CHECKOUT_REF"
125 git sparse-checkout set --no-cone '/*' '!/.repos/'
126 git -c checkout.workers=0 checkout --detach FETCH_HEAD
127​
128 # Windows installs straight from the registry. There, linking the packages
129 # takes the time, not downloading them, so a ~700 MB package cache did not
130 # pay for its own restore. Across recent nightlies, restore plus install
131 # took 183-233s on arm64 and 116-172s on x64, while a plain install took
132 # 142-210s and 84-160s. The arm64 entries also filled 4 GB of the
133 # repository's 10 GB Actions cache.
134 - name: Setup Vite+
135 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
136 with:
137 node-version-file: package.json
138 cache: ${{ inputs.platform != 'win' }}
139 run-install: false
140​
141 # pnpm checks the lockfile and policy before reusing this result. A missing
142 # artifact leaves the cache empty, so installation runs the checks again.
143 - name: Download dependency verification
144 continue-on-error: true
145 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
146 with:
147 name: release-dependency-verification
148 path: ${{ runner.temp }}/pnpm-metadata
149​
150 - name: Install desktop dependencies
151 env:
152 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
153 run: vp install --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
154​
155 - name: Cache resource monitor
156 id: resource_monitor_cache
157 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
158 with:
159 path: native/resource-monitor/target/${{ inputs.rust_target }}/release/t3-resource-monitor${{ inputs.platform == 'win' && '.exe' || '' }}
160 key: resource-monitor-${{ inputs.rust_target }}-${{ hashFiles('native/resource-monitor/Cargo.lock', 'native/resource-monitor/Cargo.toml', 'native/resource-monitor/src/**') }}
161​
162 - name: Cache Linux capture helpers
163 if: inputs.platform == 'linux'
164 id: capture_helper_cache
165 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
166 with:
167 path: |
168 native/kde-snap-shot/target/${{ inputs.rust_target }}/release/t3-kde-snap-shot
169 native/hyprland-snap-shot/target/${{ inputs.rust_target }}/release/t3-hyprland-snap-shot
170 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/**') }}
171​
172 - name: Setup Rust
173 if: steps.resource_monitor_cache.outputs.cache-hit != 'true' || (inputs.platform == 'linux' && steps.capture_helper_cache.outputs.cache-hit != 'true')
174 uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
175 with:
176 toolchain: stable
177 targets: ${{ inputs.rust_target }}
178​
179 - name: Download relay client tracing config
180 if: inputs.relay_client_tracing
181 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
182 with:
183 name: relay-client-tracing-config
184 path: ${{ runner.temp }}/relay-client-tracing
185​
186 - name: Load relay client tracing config
187 if: inputs.relay_client_tracing
188 shell: bash
189 run: |
190 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
191 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
192 echo "::add-mask::$tracing_token"
193 cat "$config_path" >> "$GITHUB_ENV"
194​
195 - name: Align package versions to release version
196 run: node scripts/update-release-package-versions.ts "${{ inputs.version }}"
197​
198 # The artifact root is `apps/` (upload-artifact keeps the least common
199 # ancestor of its paths), so extracting into `apps` restores
200 # apps/server/dist and apps/desktop/dist-electron at their build paths.
201 - name: Download JS bundle
202 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
203 with:
204 name: js-bundle
205 path: apps
206​
207 # The WSL backend runs the Linux CLI archive inside the distro, so the
208 # Windows desktop embeds the same-arch archive the release attaches.
209 - name: Download Linux CLI archive for WSL
210 if: inputs.platform == 'win'
211 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
212 with:
213 name: cli-linux-${{ inputs.arch }}
214 path: wsl-runtime
215​
216 # Only the resource monitor build needs these libraries. With a cached
217 # monitor, the desktop build's preflight skips its MSVC check, and node-pty
218 # ships prebuilt Windows binaries, so the 30-60s install is skipped too.
219 - name: Install Spectre-mitigated MSVC libs
220 if: inputs.platform == 'win' && steps.resource_monitor_cache.outputs.cache-hit != 'true'
221 shell: pwsh
222 run: |
223 $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
224 $installPath = & $vswhere -products * -latest -property installationPath
225 $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
226 $proc = Start-Process -FilePath $setupExe `
227 -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
228 "Microsoft.VisualStudio.Component.VC.Runtimes.${{ inputs.arch == 'arm64' && 'ARM64' || 'x86.x64' }}.Spectre", "--quiet", "--norestart" `
229 -Wait -PassThru -NoNewWindow
230 if ($null -eq $proc -or $proc.ExitCode -ne 0) {
231 $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
232 Write-Error "Visual Studio Installer failed with exit code $code"
233 exit $code
234 }
235​
236 - uses: ./.github/actions/setup-apt-mirrors
237 if: inputs.platform == 'linux'
238​
239 - name: Install Linux desktop build libraries
240 if: inputs.platform == 'linux'
241 shell: bash
242 run: |
243 sudo apt-get update
244 sudo apt-get install -y libsecret-1-dev pkg-config
245 if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
246 sudo apt-get install -y imagemagick
247 fi
248​
249 if command -v magick >/dev/null 2>&1; then
250 magick -version
251 else
252 convert -version
253 fi
254​
255 - name: Prepare Azure Trusted Signing
256 if: inputs.platform == 'win'
257 shell: pwsh
258 env:
259 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
260 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
261 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
262 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
263 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
264 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
265 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
266 run: |
267 $ErrorActionPreference = "Stop"
268​
269 $requiredSecrets = @(
270 $env:AZURE_TENANT_ID,
271 $env:AZURE_CLIENT_ID,
272 $env:AZURE_CLIENT_SECRET,
273 $env:AZURE_TRUSTED_SIGNING_ENDPOINT,
274 $env:AZURE_TRUSTED_SIGNING_ACCOUNT_NAME,
275 $env:AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME,
276 $env:AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
277 )
278 if ($requiredSecrets | Where-Object { [string]::IsNullOrWhiteSpace($_) }) {
279 Write-Host "Azure Trusted Signing disabled; skipping TrustedSigning module preparation."
280 exit 0
281 }
282​
283 try {
284 Install-PackageProvider `
285 -Name NuGet `
286 -MinimumVersion 2.8.5.201 `
287 -Force `
288 -Scope CurrentUser `
289 -ErrorAction Stop
290 } catch {
291 Write-Warning "Could not bootstrap NuGet package provider. Continuing because the runner may already have a usable provider. $($_.Exception.Message)"
292 }
293​
294 Install-Module `
295 -Name TrustedSigning `
296 -MinimumVersion 0.5.0 `
297 -Force `
298 -AllowClobber `
299 -Repository PSGallery `
300 -Scope CurrentUser `
301 -ErrorAction Stop
302​
303 Import-Module TrustedSigning -MinimumVersion 0.5.0 -Force
304 Get-Command Invoke-TrustedSigning -ErrorAction Stop
305​
306 $moduleRoots = @(
307 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "PowerShell", "Modules"),
308 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "WindowsPowerShell", "Modules"),
309 [System.IO.Path]::Combine($env:ProgramFiles, "PowerShell", "Modules"),
310 [System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules")
311 )
312 $modulePathEntries = @($moduleRoots + ($env:PSModulePath -split ";")) |
313 Where-Object { $_ -and (Test-Path $_) } |
314 Select-Object -Unique
315 "PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
316​
317 - name: Build desktop artifact
318 shell: bash
319 env:
320 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
321 T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: ${{ steps.resource_monitor_cache.outputs.cache-hit == 'true' }}
322 T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
323 CSC_LINK: ${{ secrets.CSC_LINK }}
324 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
325 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
326 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
327 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
328 APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
329 MACOS_PROVISIONING_PROFILE: ${{ secrets.MACOS_PROVISIONING_PROFILE }}
330 T3CODE_CLERK_PASSKEY_RP_DOMAINS: ${{ vars.CLERK_PASSKEY_RP_DOMAINS }}
331 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
332 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
333 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
334 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
335 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
336 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
337 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
338 run: |
339 args=(
340 --platform "${{ inputs.platform }}"
341 --target "${{ inputs.target }}"
342 --arch "${{ inputs.arch }}"
343 --build-version "${{ inputs.version }}"
344 --skip-build
345 --verbose
346 )
347​
348 has_all() {
349 for value in "$@"; do
350 if [[ -z "$value" ]]; then
351 return 1
352 fi
353 done
354 return 0
355 }
356​
357 if [[ "${{ inputs.platform }}" == "mac" ]]; then
358 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
359 if ! has_all "$APPLE_TEAM_ID" "$MACOS_PROVISIONING_PROFILE"; then
360 echo "macOS signing is configured, but APPLE_TEAM_ID or MACOS_PROVISIONING_PROFILE is missing." >&2
361 exit 1
362 fi
363​
364 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
365 printf '%s' "$APPLE_API_KEY" > "$key_path"
366 export APPLE_API_KEY="$key_path"
367​
368 profile_path="$RUNNER_TEMP/t3code.provisionprofile"
369 printf '%s' "$MACOS_PROVISIONING_PROFILE" | base64 -D > "$profile_path"
370 security cms -D -i "$profile_path" >/dev/null
371 export T3CODE_APPLE_TEAM_ID="$APPLE_TEAM_ID"
372 export T3CODE_MACOS_PROVISIONING_PROFILE="$profile_path"
373​
374 echo "macOS signing enabled."
375 args+=(--signed)
376 else
377 echo "macOS signing disabled (missing one or more Apple signing secrets)."
378 fi
379 elif [[ "${{ inputs.platform }}" == "win" ]]; then
380 # Embed the Linux CLI archive built by the same-arch Linux job as
381 # the WSL runtime. Required for a working WSL backend on Windows.
382 args+=(--wsl-runtime "$GITHUB_WORKSPACE"/wsl-runtime/t3-*-linux-${{ inputs.arch }}.tar.gz)
383 if has_all \
384 "$AZURE_TENANT_ID" \
385 "$AZURE_CLIENT_ID" \
386 "$AZURE_CLIENT_SECRET" \
387 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
388 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
389 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
390 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
391 echo "Windows signing enabled (Azure Trusted Signing)."
392 args+=(--signed)
393 else
394 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
395 fi
396 else
397 echo "Signing disabled for ${{ inputs.platform }}."
398 fi
399​
400 vp run dist:desktop:artifact "${args[@]}"
401​
402 # The single-executable is built with a Node that supports --build-sea
403 # (25.7+); the repo itself stays on the engines.node version. It always
404 # injects into the runner's own Node: tsdown's cross-target download path
405 # runs `tar` on a drive-letter path on Windows, which GNU tar reads as a
406 # remote host, and a cross-built macOS binary cannot be smoke-tested.
407 - name: Build CLI single-executable
408 if: inputs.cli_archive
409 shell: bash
410 env:
411 # The exact version, not a major: vp downloads it from nodejs.org/dist on
412 # the runner, and only exact versions have a dist directory. Keep in
413 # step with SEA_NODE_VERSION in apps/server/vite.config.ts.
414 VP_NODE_VERSION: "26.8.2"
415 run: node apps/server/scripts/cli.ts build-exe --verbose
416​
417 - name: Import macOS signing certificate for the CLI archive
418 if: inputs.cli_archive && inputs.platform == 'mac'
419 shell: bash
420 env:
421 CSC_LINK: ${{ secrets.CSC_LINK }}
422 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
423 run: |
424 set -euo pipefail
425 if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" ]]; then
426 echo "macOS CLI signing disabled (missing CSC_LINK); the archive is signed ad hoc."
427 exit 0
428 fi
429 keychain="$RUNNER_TEMP/t3-cli-signing.keychain-db"
430 keychain_password="$(openssl rand -hex 16)"
431 cert_path="$RUNNER_TEMP/t3-cli-signing.p12"
432 printf '%s' "$CSC_LINK" | base64 --decode > "$cert_path"
433 security create-keychain -p "$keychain_password" "$keychain"
434 security set-keychain-settings -lut 21600 "$keychain"
435 security unlock-keychain -p "$keychain_password" "$keychain"
436 security import "$cert_path" -k "$keychain" -P "$CSC_KEY_PASSWORD" -T /usr/bin/codesign
437 security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" >/dev/null
438 security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
439 identity="$(security find-identity -v -p codesigning "$keychain" | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -n 1)"
440 if [[ -z "$identity" ]]; then
441 echo "No Developer ID Application identity found in CSC_LINK." >&2
442 exit 1
443 fi
444 echo "::add-mask::$keychain_password"
445 echo "T3CODE_CLI_MAC_SIGN_IDENTITY=$identity" >> "$GITHUB_ENV"
446 echo "macOS CLI signing enabled."
447​
448 - name: Stage resource monitor for the CLI archive
449 if: inputs.cli_archive
450 shell: bash
451 run: |
452 set -euo pipefail
453 binary_name="t3-resource-monitor"
454 if [[ "${{ inputs.platform }}" == "win" ]]; then
455 binary_name="${binary_name}.exe"
456 fi
457 target_dir="$RUNNER_TEMP/cli-resource-monitor/${{ inputs.resource_key }}"
458 mkdir -p "$target_dir"
459 cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
460​
461 - name: Build CLI archive
462 if: inputs.cli_archive
463 shell: bash
464 env:
465 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
466 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
467 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
468 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
469 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
470 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
471 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
472 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
473 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
474 run: |
475 set -euo pipefail
476 if [[ "${{ inputs.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then
477 key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"
478 printf '%s' "$APPLE_API_KEY" > "$key_path"
479 export APPLE_API_KEY="$key_path"
480 fi
481 node scripts/build-cli-archive.ts \
482 --platform "${{ inputs.platform }}" \
483 --arch "${{ inputs.arch }}" \
484 --version "${{ inputs.version }}" \
485 --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \
486 --output-dir release-cli
487​
488 - name: Smoke-test CLI archive
489 if: inputs.cli_archive
490 shell: bash
491 run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ inputs.version }}"
492​
493 - name: Upload CLI archive
494 if: inputs.cli_archive
495 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
496 with:
497 name: cli-${{ inputs.platform }}-${{ inputs.arch }}
498 path: release-cli/*
499 if-no-files-found: error
500​
501 - name: Collect release assets
502 shell: bash
503 run: |
504 set -euo pipefail
505 mkdir -p release-publish
506​
507 shopt -s nullglob
508 patterns=(
509 "release/*.dmg"
510 "release/*.zip"
511 "release/*.AppImage"
512 "release/*.deb"
513 "release/*.exe"
514 )
515 # Preview builds have no publish config, so electron-builder writes
516 # no feed manifest for them, but it still emits blockmaps beside the
517 # installers. Neither belongs on a release no updater may follow.
518 if [[ "${{ inputs.release_channel }}" != "preview" ]]; then
519 patterns+=("release/*.blockmap" "release/*.yml")
520 fi
521 for pattern in "${patterns[@]}"; do
522 for file in $pattern; do
523 cp "$file" release-publish/
524 done
525 done
526​
527 if [[ "${{ inputs.platform }}" == "mac" && "${{ inputs.arch }}" != "arm64" ]]; then
528 shopt -s nullglob
529 for manifest in release-publish/*-mac.yml; do
530 mv "$manifest" "${manifest%.yml}-${{ inputs.arch }}.yml"
531 done
532 fi
533​
534 # Windows updater metadata is channel-specific (for example
535 # "latest.yml" or "nightly.yml") and carries no arch, so the x64 and
536 # arm64 jobs would upload the same name. Suffix each per-arch copy;
537 # the release job merges them back into one manifest per channel.
538 # builder-debug.yml is electron-builder's config dump, not a feed.
539 if [[ "${{ inputs.platform }}" == "win" ]]; then
540 for manifest in release-publish/*.yml; do
541 [[ "$manifest" == */builder-debug.yml ]] && continue
542 mv "$manifest" "${manifest%.yml}-win-${{ inputs.arch }}.yml"
543 done
544 fi
545​
546 - name: Collect resource monitor
547 shell: bash
548 run: |
549 set -euo pipefail
550 binary_name="t3-resource-monitor"
551 if [[ "${{ inputs.platform }}" == "win" ]]; then
552 binary_name="${binary_name}.exe"
553 fi
554 source_path="native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}"
555 target_dir="resource-monitor-publish/${{ inputs.resource_key }}"
556 mkdir -p "$target_dir"
557 cp "$source_path" "$target_dir/$binary_name"
558​
559 - name: Upload build artifacts
560 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
561 with:
562 name: desktop-${{ inputs.platform }}-${{ inputs.arch }}
563 path: release-publish/*
564 if-no-files-found: error
565​
566 - name: Upload resource monitor
567 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
568 with:
569 name: resource-monitor-${{ inputs.resource_key }}
570 path: resource-monitor-publish/${{ inputs.resource_key }}/*
571 if-no-files-found: error