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

release-desktop.yml

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