Open History to see the last commit
1name: Release
2
3on:
4 push:
5 tags:
6 - "v*.*.*"
7 - "!v*-nightly.*"
8 schedule:
9 - cron: "0 */3 * * *"
10 workflow_dispatch:
11 inputs:
12 channel:
13 description: "Release channel"
14 required: false
15 default: stable
16 type: choice
17 options:
18 - stable
19 - nightly
20 version:
21 description: "Release version (for example 1.2.3 or v1.2.3)"
22 required: false
23 type: string
24
25permissions:
26 contents: read
27 id-token: none
28
29jobs:
30 check_changes:
31 name: Check for changes since last nightly
32 if: github.event_name == 'schedule'
33 runs-on: blacksmith-8vcpu-ubuntu-2404
34 outputs:
35 has_changes: ${{ steps.check.outputs.has_changes }}
36 steps:
37 - name: Checkout
38 uses: actions/checkout@v6
39 with:
40 fetch-depth: 0
41
42 - id: check
43 name: Compare HEAD to last nightly tag
44 run: |
45 last_nightly_tag=$(git tag --list 'v*-nightly.*' 'nightly-v*' --sort=-creatordate | head -n 1)
46 if [[ -z "$last_nightly_tag" ]]; then
47 echo "No previous nightly tag found. Proceeding with release."
48 echo "has_changes=true" >> "$GITHUB_OUTPUT"
49 exit 0
50 fi
51
52 last_nightly_sha=$(git rev-parse "$last_nightly_tag^{commit}")
53 head_sha=$(git rev-parse HEAD)
54
55 if [[ "$last_nightly_sha" == "$head_sha" ]]; then
56 echo "No changes on main since last nightly release ($last_nightly_tag). Skipping."
57 echo "has_changes=false" >> "$GITHUB_OUTPUT"
58 else
59 echo "Changes detected on main since $last_nightly_tag ($last_nightly_sha → $head_sha). Proceeding."
60 echo "has_changes=true" >> "$GITHUB_OUTPUT"
61 fi
62
63 preflight:
64 name: Preflight
65 needs: [check_changes]
66 if: |
67 !failure() && !cancelled() &&
68 (github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
69 runs-on: blacksmith-8vcpu-ubuntu-2404
70 timeout-minutes: 10
71 outputs:
72 release_channel: ${{ steps.release_meta.outputs.release_channel }}
73 version: ${{ steps.release_meta.outputs.version }}
74 tag: ${{ steps.release_meta.outputs.tag }}
75 release_name: ${{ steps.release_meta.outputs.name }}
76 short_sha: ${{ steps.release_meta.outputs.short_sha }}
77 previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
78 cli_dist_tag: ${{ steps.release_meta.outputs.cli_dist_tag }}
79 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
80 make_latest: ${{ steps.release_meta.outputs.make_latest }}
81 ref: ${{ github.sha }}
82 steps:
83 - name: Checkout
84 uses: actions/checkout@v6
85 with:
86 fetch-depth: 0
87
88 - name: Setup Vite+
89 uses: voidzero-dev/setup-vp@v1
90 with:
91 node-version-file: package.json
92 cache: true
93 run-install: true
94
95 - name: Ensure Electron runtime is installed
96 run: vp run --filter @t3tools/desktop ensure:electron
97
98 - id: release_meta
99 name: Resolve release version
100 shell: bash
101 env:
102 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
103 DISPATCH_VERSION: ${{ github.event.inputs.version }}
104 NIGHTLY_DATE: ${{ github.run_started_at }}
105 NIGHTLY_SHA: ${{ github.sha }}
106 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
107 run: |
108 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ) ]]; then
109 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
110
111 node scripts/resolve-nightly-release.ts \
112 --date "$nightly_date" \
113 --run-number "$NIGHTLY_RUN_NUMBER" \
114 --sha "$NIGHTLY_SHA" \
115 --github-output
116
117 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
118 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
119 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
120 echo "make_latest=false" >> "$GITHUB_OUTPUT"
121 else
122 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
123 raw="${DISPATCH_VERSION}"
124 if [[ -z "$raw" ]]; then
125 echo "workflow_dispatch stable releases require the version input." >&2
126 exit 1
127 fi
128 else
129 raw="${GITHUB_REF_NAME}"
130 fi
131
132 version="${raw#v}"
133 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
134 echo "Invalid release version: $raw" >&2
135 exit 1
136 fi
137
138 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
139 echo "version=$version" >> "$GITHUB_OUTPUT"
140 echo "tag=v$version" >> "$GITHUB_OUTPUT"
141 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
142 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
143 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
144 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
145 echo "make_latest=true" >> "$GITHUB_OUTPUT"
146 else
147 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
148 echo "make_latest=false" >> "$GITHUB_OUTPUT"
149 fi
150 fi
151
152 - name: Check
153 run: vp check
154
155 - name: Typecheck
156 run: vp run typecheck
157
158 - name: Test
159 run: vp run test
160
161 - id: previous_tag
162 name: Resolve previous release tag
163 run: |
164 node scripts/resolve-previous-release-tag.ts \
165 --channel "${{ steps.release_meta.outputs.release_channel }}" \
166 --current-tag "${{ steps.release_meta.outputs.tag }}" \
167 --github-output
168
169 relay_public_config:
170 name: Resolve T3 Connect public config
171 needs: preflight
172 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
173 runs-on: blacksmith-8vcpu-ubuntu-2404
174 timeout-minutes: 5
175 environment:
176 name: production
177 outputs:
178 clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
179 clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
180 clerk_cli_oauth_client_id: ${{ steps.public_config.outputs.clerk_cli_oauth_client_id }}
181 relay_url: ${{ steps.public_config.outputs.relay_url }}
182 env:
183 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
184 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
185 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
186 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
187 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
188 CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }}
189 CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }}
190 steps:
191 - name: Checkout
192 uses: actions/checkout@v6
193 with:
194 ref: ${{ needs.preflight.outputs.ref }}
195
196 - name: Setup Vite+
197 uses: voidzero-dev/setup-vp@v1
198 with:
199 node-version-file: package.json
200 cache: true
201 run-install: |
202 args:
203 - --filter=t3code-relay...
204
205 - id: relay_state
206 name: Read production relay tracing config
207 shell: bash
208 run: |
209 vp run --filter t3code-relay deploy \
210 --stage prod \
211 --read-state \
212 --github-output \
213 --github-env-file "$RUNNER_TEMP/relay-client-tracing.env"
214
215 - name: Upload relay client tracing config
216 uses: actions/upload-artifact@v7
217 with:
218 name: relay-client-tracing-config
219 path: ${{ runner.temp }}/relay-client-tracing.env
220 if-no-files-found: error
221 retention-days: 1
222
223 - id: public_config
224 name: Resolve production relay public config
225 shell: bash
226 run: |
227 set -euo pipefail
228
229 relay_domain="${RELAY_DOMAIN:-}"
230 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
231 relay_domain="relay.$RELAY_API_ZONE_NAME"
232 fi
233 required=(
234 relay_domain
235 CLERK_PUBLISHABLE_KEY
236 CLERK_JWT_TEMPLATE
237 CLERK_CLI_OAUTH_CLIENT_ID
238 )
239 missing=()
240 for name in "${required[@]}"; do
241 if [[ -z "${!name:-}" ]]; then
242 missing+=("$name")
243 fi
244 done
245 if (( ${#missing[@]} > 0 )); then
246 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
247 exit 1
248 fi
249
250 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
251 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
252 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
253 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
254
255 # node-pty publishes no Linux prebuilt and the WSL backend runs under the
256 # distro's own (Linux) Node, which can't load the Windows/Electron binary. We
257 # build the Linux pty.node here, on Linux, and hand it to the Windows packaging
258 # job — the Windows artifact then ships a ready WSL backend binary with no
259 # cross-compiling and no first-launch compiler/node-gyp/network on the user's
260 # machine. node-pty is N-API, so one binary works across all WSL Node versions.
261 build_wsl_node_pty:
262 name: Build WSL node-pty (linux-x64)
263 needs: [preflight]
264 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
265 runs-on: blacksmith-8vcpu-ubuntu-2404
266 timeout-minutes: 15
267 steps:
268 - name: Checkout
269 uses: actions/checkout@v6
270 with:
271 ref: ${{ needs.preflight.outputs.ref }}
272 fetch-depth: 0
273
274 - name: Setup Vite+
275 uses: voidzero-dev/setup-vp@v1
276 with:
277 node-version-file: package.json
278 cache: true
279 run-install: true
280
281 - name: Build node-pty linux-x64 prebuild
282 shell: bash
283 run: |
284 set -euo pipefail
285 # Resolve node-pty from apps/server (where it's a dependency) and build
286 # its native binary from source for Linux. node-addon-api resolves from
287 # node-pty's own dependency tree, so node-gyp has everything it needs.
288 pty_pkg="$(node -e "console.log(require.resolve('node-pty/package.json', { paths: ['$GITHUB_WORKSPACE/apps/server'] }))")"
289 pty_dir="$(dirname "$pty_pkg")"
290 ( cd "$pty_dir" && npx --yes node-gyp rebuild )
291 mkdir -p wsl-prebuild
292 cp "$pty_dir/build/Release/pty.node" wsl-prebuild/pty.node
293 file wsl-prebuild/pty.node
294
295 - name: Upload node-pty linux-x64 prebuild
296 uses: actions/upload-artifact@v7
297 with:
298 name: wsl-node-pty-x64
299 path: wsl-prebuild/pty.node
300 if-no-files-found: error
301
302 build:
303 name: Build ${{ matrix.label }}
304 # build_wsl_node_pty stays in `needs` so it runs first and its artifact is
305 # available to download, but only the Windows matrix entry consumes it. We
306 # therefore gate the job on preflight + relay (must succeed) WITHOUT requiring
307 # build_wsl_node_pty, so a failed Linux prebuild doesn't skip the macOS/Linux
308 # builds. `!cancelled()` (not `!failure()`) lets the job run even when
309 # build_wsl_node_pty failed; the Windows-only download step below then fails
310 # that single platform if the prebuild is missing.
311 needs: [preflight, relay_public_config, build_wsl_node_pty]
312 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
313 runs-on: ${{ matrix.runner }}
314 timeout-minutes: 30
315 env:
316 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
317 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
318 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
319 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
320 strategy:
321 fail-fast: false
322 matrix:
323 include:
324 - label: macOS arm64
325 runner: blacksmith-12vcpu-macos-26
326 platform: mac
327 target: dmg
328 arch: arm64
329 rust_target: aarch64-apple-darwin
330 resource_key: darwin-arm64
331 - label: macOS x64
332 runner: blacksmith-12vcpu-macos-26
333 platform: mac
334 target: dmg
335 arch: x64
336 rust_target: x86_64-apple-darwin
337 resource_key: darwin-x64
338 - label: Linux x64
339 runner: blacksmith-32vcpu-ubuntu-2404
340 platform: linux
341 target: AppImage
342 arch: x64
343 rust_target: x86_64-unknown-linux-gnu
344 resource_key: linux-x64
345 - label: Windows x64
346 runner: blacksmith-32vcpu-windows-2025
347 platform: win
348 target: nsis
349 arch: x64
350 rust_target: x86_64-pc-windows-msvc
351 resource_key: win32-x64
352 # - label: Windows arm64
353 # runner: windows-11-arm
354 # platform: win
355 # target: nsis
356 # arch: arm64
357 steps:
358 - name: Checkout
359 uses: actions/checkout@v6
360 with:
361 ref: ${{ needs.preflight.outputs.ref }}
362 fetch-depth: 0
363
364 - name: Setup Vite+
365 uses: voidzero-dev/setup-vp@v1
366 with:
367 node-version-file: package.json
368 cache: true
369 run-install: true
370
371 - name: Setup Rust
372 uses: dtolnay/rust-toolchain@stable
373 with:
374 targets: ${{ matrix.rust_target }}
375
376 - name: Download relay client tracing config
377 uses: actions/download-artifact@v8
378 with:
379 name: relay-client-tracing-config
380 path: ${{ runner.temp }}/relay-client-tracing
381
382 - name: Load relay client tracing config
383 shell: bash
384 run: |
385 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
386 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
387 echo "::add-mask::$tracing_token"
388 cat "$config_path" >> "$GITHUB_ENV"
389
390 - name: Align package versions to release version
391 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
392
393 - name: Download WSL node-pty prebuild
394 if: matrix.platform == 'win'
395 uses: actions/download-artifact@v7
396 with:
397 name: wsl-node-pty-x64
398 path: wsl-prebuild
399
400 - name: Install Spectre-mitigated MSVC libs
401 if: matrix.platform == 'win'
402 shell: pwsh
403 run: |
404 $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
405 $installPath = & $vswhere -products * -latest -property installationPath
406 $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
407 $proc = Start-Process -FilePath $setupExe `
408 -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
409 "Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre", "--quiet", "--norestart" `
410 -Wait -PassThru -NoNewWindow
411 if ($null -eq $proc -or $proc.ExitCode -ne 0) {
412 $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
413 Write-Error "Visual Studio Installer failed with exit code $code"
414 exit $code
415 }
416
417 - name: Install ImageMagick
418 if: matrix.platform == 'linux'
419 shell: bash
420 run: |
421 if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
422 sudo apt-get update
423 sudo apt-get install -y imagemagick
424 fi
425
426 if command -v magick >/dev/null 2>&1; then
427 magick -version
428 else
429 convert -version
430 fi
431
432 - name: Prepare Azure Trusted Signing
433 if: matrix.platform == 'win'
434 shell: pwsh
435 env:
436 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
437 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
438 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
439 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
440 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
441 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
442 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
443 run: |
444 $ErrorActionPreference = "Stop"
445
446 $requiredSecrets = @(
447 $env:AZURE_TENANT_ID,
448 $env:AZURE_CLIENT_ID,
449 $env:AZURE_CLIENT_SECRET,
450 $env:AZURE_TRUSTED_SIGNING_ENDPOINT,
451 $env:AZURE_TRUSTED_SIGNING_ACCOUNT_NAME,
452 $env:AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME,
453 $env:AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
454 )
455 if ($requiredSecrets | Where-Object { [string]::IsNullOrWhiteSpace($_) }) {
456 Write-Host "Azure Trusted Signing disabled; skipping TrustedSigning module preparation."
457 exit 0
458 }
459
460 try {
461 Install-PackageProvider `
462 -Name NuGet `
463 -MinimumVersion 2.8.5.201 `
464 -Force `
465 -Scope CurrentUser `
466 -ErrorAction Stop
467 } catch {
468 Write-Warning "Could not bootstrap NuGet package provider. Continuing because the runner may already have a usable provider. $($_.Exception.Message)"
469 }
470
471 Install-Module `
472 -Name TrustedSigning `
473 -MinimumVersion 0.5.0 `
474 -Force `
475 -AllowClobber `
476 -Repository PSGallery `
477 -Scope CurrentUser `
478 -ErrorAction Stop
479
480 Import-Module TrustedSigning -MinimumVersion 0.5.0 -Force
481 Get-Command Invoke-TrustedSigning -ErrorAction Stop
482
483 $moduleRoots = @(
484 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "PowerShell", "Modules"),
485 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "WindowsPowerShell", "Modules"),
486 [System.IO.Path]::Combine($env:ProgramFiles, "PowerShell", "Modules"),
487 [System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules")
488 )
489 $modulePathEntries = @($moduleRoots + ($env:PSModulePath -split ";")) |
490 Where-Object { $_ -and (Test-Path $_) } |
491 Select-Object -Unique
492 "PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
493
494 - name: Build desktop artifact
495 shell: bash
496 env:
497 CSC_LINK: ${{ secrets.CSC_LINK }}
498 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
499 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
500 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
501 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
502 APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
503 MACOS_PROVISIONING_PROFILE: ${{ secrets.MACOS_PROVISIONING_PROFILE }}
504 T3CODE_CLERK_PASSKEY_RP_DOMAINS: ${{ vars.CLERK_PASSKEY_RP_DOMAINS }}
505 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
506 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
507 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
508 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
509 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
510 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
511 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
512 run: |
513 args=(
514 --platform "${{ matrix.platform }}"
515 --target "${{ matrix.target }}"
516 --arch "${{ matrix.arch }}"
517 --build-version "${{ needs.preflight.outputs.version }}"
518 --verbose
519 )
520
521 has_all() {
522 for value in "$@"; do
523 if [[ -z "$value" ]]; then
524 return 1
525 fi
526 done
527 return 0
528 }
529
530 if [[ "${{ matrix.platform }}" == "mac" ]]; then
531 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
532 if ! has_all "$APPLE_TEAM_ID" "$MACOS_PROVISIONING_PROFILE"; then
533 echo "macOS signing is configured, but APPLE_TEAM_ID or MACOS_PROVISIONING_PROFILE is missing." >&2
534 exit 1
535 fi
536
537 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
538 printf '%s' "$APPLE_API_KEY" > "$key_path"
539 export APPLE_API_KEY="$key_path"
540
541 profile_path="$RUNNER_TEMP/t3code.provisionprofile"
542 printf '%s' "$MACOS_PROVISIONING_PROFILE" | base64 -D > "$profile_path"
543 security cms -D -i "$profile_path" >/dev/null
544 export T3CODE_APPLE_TEAM_ID="$APPLE_TEAM_ID"
545 export T3CODE_MACOS_PROVISIONING_PROFILE="$profile_path"
546
547 echo "macOS signing enabled."
548 args+=(--signed)
549 else
550 echo "macOS signing disabled (missing one or more Apple signing secrets)."
551 fi
552 elif [[ "${{ matrix.platform }}" == "win" ]]; then
553 # Bundle the Linux node-pty binary built by the build_wsl_node_pty job
554 # so the packaged WSL backend ships a ready binary (no first-launch
555 # compile). Required for a working WSL backend on Windows.
556 args+=(--wsl-prebuild "$GITHUB_WORKSPACE/wsl-prebuild/pty.node")
557 if has_all \
558 "$AZURE_TENANT_ID" \
559 "$AZURE_CLIENT_ID" \
560 "$AZURE_CLIENT_SECRET" \
561 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
562 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
563 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
564 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
565 echo "Windows signing enabled (Azure Trusted Signing)."
566 args+=(--signed)
567 else
568 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
569 fi
570 else
571 echo "Signing disabled for ${{ matrix.platform }}."
572 fi
573
574 vp run dist:desktop:artifact "${args[@]}"
575
576 - name: Collect release assets
577 shell: bash
578 run: |
579 set -euo pipefail
580 mkdir -p release-publish
581
582 shopt -s nullglob
583 for pattern in \
584 "release/*.dmg" \
585 "release/*.zip" \
586 "release/*.AppImage" \
587 "release/*.exe" \
588 "release/*.blockmap" \
589 "release/*.yml"; do
590 for file in $pattern; do
591 cp "$file" release-publish/
592 done
593 done
594
595 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
596 shopt -s nullglob
597 for manifest in release-publish/*-mac.yml; do
598 mv "$manifest" "${manifest%.yml}-${{ matrix.arch }}.yml"
599 done
600 fi
601
602 # Enable if Windows arm64 builds are enabled.
603 # Windows updater metadata is channel-specific (for example
604 # "latest.yml" or "nightly.yml"). Suffix each per-arch copy so the
605 # release job can merge matching arm64/x64 manifests back into one
606 # canonical manifest per channel.
607 # if [[ "${{ matrix.platform }}" == "win" ]]; then
608 # shopt -s nullglob
609 # for manifest in release-publish/*.yml; do
610 # mv "$manifest" "${manifest%.yml}-win-${{ matrix.arch }}.yml"
611 # done
612 # fi
613
614 - name: Collect resource monitor
615 shell: bash
616 run: |
617 set -euo pipefail
618 binary_name="t3-resource-monitor"
619 if [[ "${{ matrix.platform }}" == "win" ]]; then
620 binary_name="${binary_name}.exe"
621 fi
622 source_path="native/resource-monitor/target/${{ matrix.rust_target }}/release/${binary_name}"
623 target_dir="resource-monitor-publish/${{ matrix.resource_key }}"
624 mkdir -p "$target_dir"
625 cp "$source_path" "$target_dir/$binary_name"
626
627 - name: Upload build artifacts
628 uses: actions/upload-artifact@v7
629 with:
630 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
631 path: release-publish/*
632 if-no-files-found: error
633
634 - name: Upload resource monitor
635 uses: actions/upload-artifact@v7
636 with:
637 name: resource-monitor-${{ matrix.resource_key }}
638 path: resource-monitor-publish/${{ matrix.resource_key }}/*
639 if-no-files-found: error
640
641 publish_cli:
642 name: Publish CLI to npm
643 needs: [preflight, relay_public_config, build]
644 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build.result == 'success' }}
645 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
646 timeout-minutes: 10
647 permissions:
648 contents: read
649 id-token: write
650 env:
651 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
652 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
653 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
654 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
655 steps:
656 - name: Checkout
657 uses: actions/checkout@v6
658 with:
659 ref: ${{ needs.preflight.outputs.ref }}
660
661 - name: Setup Vite+
662 uses: voidzero-dev/setup-vp@v1
663 with:
664 node-version-file: package.json
665 cache: true
666 run-install: |
667 args:
668 - --filter=t3...
669 - --filter=@t3tools/web...
670 - --filter=@t3tools/scripts...
671
672 - name: Download relay client tracing config
673 uses: actions/download-artifact@v8
674 with:
675 name: relay-client-tracing-config
676 path: ${{ runner.temp }}/relay-client-tracing
677
678 - name: Load relay client tracing config
679 shell: bash
680 run: |
681 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
682 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
683 echo "::add-mask::$tracing_token"
684 cat "$config_path" >> "$GITHUB_ENV"
685
686 - name: Align package versions to release version
687 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
688
689 - name: Build web package
690 run: vp run --filter @t3tools/web build
691
692 - name: Build CLI package
693 run: vp run --filter t3 build
694
695 - name: Download resource monitors
696 uses: actions/download-artifact@v8
697 with:
698 pattern: resource-monitor-*
699 path: ${{ runner.temp }}/resource-monitors
700
701 - name: Bundle resource monitors into CLI package
702 shell: bash
703 run: |
704 set -euo pipefail
705 for artifact_dir in "$RUNNER_TEMP"/resource-monitors/resource-monitor-*; do
706 resource_key="${artifact_dir##*/resource-monitor-}"
707 target_dir="apps/server/dist/resource-monitor/${resource_key}"
708 mkdir -p "$target_dir"
709 cp "$artifact_dir"/t3-resource-monitor* "$target_dir/"
710 chmod +x "$target_dir"/t3-resource-monitor 2>/dev/null || true
711 done
712
713 - name: Publish CLI package
714 run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
715
716 release:
717 name: Publish GitHub Release
718 needs: [preflight, build, publish_cli]
719 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' && needs.publish_cli.result == 'success' }}
720 runs-on: blacksmith-8vcpu-ubuntu-2404
721 timeout-minutes: 10
722 steps:
723 - id: app_token
724 name: Mint release app token
725 uses: actions/create-github-app-token@v2
726 with:
727 app-id: ${{ secrets.RELEASE_APP_ID }}
728 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
729 owner: ${{ github.repository_owner }}
730
731 - name: Checkout
732 uses: actions/checkout@v6
733 with:
734 ref: ${{ needs.preflight.outputs.ref }}
735
736 - name: Setup Vite+
737 uses: voidzero-dev/setup-vp@v1
738 with:
739 node-version-file: package.json
740 cache: true
741 run-install: |
742 args:
743 - --filter=@t3tools/scripts...
744
745 - name: Download all desktop artifacts
746 uses: actions/download-artifact@v8
747 with:
748 pattern: desktop-*
749 merge-multiple: true
750 path: release-assets
751
752 - name: Merge macOS updater manifests
753 run: |
754 shopt -s nullglob
755 for x64_manifest in release-assets/*-mac-x64.yml; do
756 arm64_manifest="${x64_manifest%-x64.yml}.yml"
757 if [[ -f "$arm64_manifest" ]]; then
758 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
759 rm -f "$x64_manifest"
760 fi
761 done
762
763 # - name: Merge Windows updater manifests
764 # run: |
765 # shopt -s nullglob
766 # found_windows_manifest=false
767 # for x64_manifest in release-assets/*-win-x64.yml; do
768 # if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
769 # continue
770 # fi
771
772 # arm64_manifest="${x64_manifest/-x64.yml/-arm64.yml}"
773 # output_manifest="${x64_manifest/-win-x64.yml/.yml}"
774 # if [[ ! -f "$arm64_manifest" ]]; then
775 # echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
776 # exit 1
777 # fi
778
779 # found_windows_manifest=true
780 # node scripts/merge-update-manifests.ts --platform win \
781 # "$arm64_manifest" \
782 # "$x64_manifest" \
783 # "$output_manifest"
784 # rm -f "$arm64_manifest" "$x64_manifest"
785 # done
786
787 # if [[ "$found_windows_manifest" != true ]]; then
788 # echo "No Windows updater manifests found to merge." >&2
789 # exit 1
790 # fi
791
792 - name: Publish release
793 if: needs.preflight.outputs.previous_tag != ''
794 uses: softprops/action-gh-release@v2
795 with:
796 tag_name: ${{ needs.preflight.outputs.tag }}
797 target_commitish: ${{ needs.preflight.outputs.ref }}
798 name: ${{ needs.preflight.outputs.release_name }}
799 generate_release_notes: true
800 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
801 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
802 make_latest: ${{ needs.preflight.outputs.make_latest }}
803 files: |
804 release-assets/*.dmg
805 release-assets/*.zip
806 release-assets/*.AppImage
807 release-assets/*.exe
808 release-assets/*.blockmap
809 release-assets/*.yml
810 fail_on_unmatched_files: true
811 token: ${{ steps.app_token.outputs.token }}
812
813 - name: Publish first release
814 if: needs.preflight.outputs.previous_tag == ''
815 uses: softprops/action-gh-release@v2
816 with:
817 tag_name: ${{ needs.preflight.outputs.tag }}
818 target_commitish: ${{ needs.preflight.outputs.ref }}
819 name: ${{ needs.preflight.outputs.release_name }}
820 generate_release_notes: true
821 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
822 make_latest: ${{ needs.preflight.outputs.make_latest }}
823 files: |
824 release-assets/*.dmg
825 release-assets/*.zip
826 release-assets/*.AppImage
827 release-assets/*.exe
828 release-assets/*.blockmap
829 release-assets/*.yml
830 fail_on_unmatched_files: true
831 token: ${{ steps.app_token.outputs.token }}
832
833 deploy_web:
834 name: Deploy hosted web app
835 needs: [preflight, relay_public_config, release]
836 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.release.result == 'success' }}
837 runs-on: blacksmith-8vcpu-ubuntu-2404
838 timeout-minutes: 10
839 env:
840 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
841 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
842 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
843 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
844 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
845 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
846 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
847 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
848 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
849 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
850 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
851 steps:
852 - name: Checkout
853 uses: actions/checkout@v6
854 with:
855 ref: ${{ needs.preflight.outputs.ref }}
856
857 - name: Setup Vite+
858 uses: voidzero-dev/setup-vp@v1
859 with:
860 node-version-file: package.json
861 cache: true
862 run-install: |
863 args:
864 - --filter=@t3tools/scripts...
865 - --filter=@t3tools/web...
866
867 - name: Download relay client tracing config
868 uses: actions/download-artifact@v8
869 with:
870 name: relay-client-tracing-config
871 path: ${{ runner.temp }}/relay-client-tracing
872
873 - name: Load relay client tracing config
874 shell: bash
875 run: |
876 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
877 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
878 echo "::add-mask::$tracing_token"
879 cat "$config_path" >> "$GITHUB_ENV"
880
881 - name: Align package versions to release version
882 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
883
884 - name: Refresh release lockfile
885 run: vp install --lockfile-only --ignore-scripts
886
887 - name: Deploy and alias channel
888 shell: bash
889 run: |
890 set -euo pipefail
891
892 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
893 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
894 exit 1
895 fi
896
897 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
898 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
899 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
900 router_domain="${router_url#http://}"
901 router_domain="${router_domain#https://}"
902 router_domain="${router_domain%%/*}"
903
904 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
905 channel_domain="$latest_domain"
906 channel_name="latest"
907 else
908 channel_domain="$nightly_domain"
909 channel_name="nightly"
910 fi
911
912 vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
913 vercel_scope_args=(--scope "$vercel_scope")
914
915 echo "Deploying hosted web app for $channel_name channel."
916 deployment_url="$(
917 vp dlx vercel@53.1.1 deploy \
918 --archive=tgz \
919 --prod \
920 --skip-domain \
921 --yes \
922 --token "$VERCEL_TOKEN" \
923 "${vercel_scope_args[@]}" \
924 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
925 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
926 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
927 --build-env "T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=${T3CODE_CLERK_CLI_OAUTH_CLIENT_ID:-}" \
928 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
929 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
930 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
931 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
932 --build-env "VITE_HOSTED_APP_URL=$router_url" \
933 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
934 )"
935
936 echo "Aliasing $deployment_url to $channel_domain."
937 vp dlx vercel@53.1.1 alias set "$deployment_url" "$channel_domain" \
938 --token "$VERCEL_TOKEN" \
939 "${vercel_scope_args[@]}"
940
941 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
942 echo "Aliasing $deployment_url to router domain $router_domain."
943 vp dlx vercel@53.1.1 alias set "$deployment_url" "$router_domain" \
944 --token "$VERCEL_TOKEN" \
945 "${vercel_scope_args[@]}"
946 fi
947
948 finalize:
949 name: Finalize release
950 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
951 needs: [preflight, release]
952 runs-on: blacksmith-8vcpu-ubuntu-2404
953 timeout-minutes: 10
954 steps:
955 - id: app_token
956 name: Mint release app token
957 uses: actions/create-github-app-token@v2
958 with:
959 app-id: ${{ secrets.RELEASE_APP_ID }}
960 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
961 owner: ${{ github.repository_owner }}
962
963 - name: Checkout
964 uses: actions/checkout@v6
965 with:
966 ref: main
967 fetch-depth: 0
968 token: ${{ steps.app_token.outputs.token }}
969 persist-credentials: true
970
971 - id: app_bot
972 name: Resolve GitHub App bot identity
973 env:
974 GH_TOKEN: ${{ steps.app_token.outputs.token }}
975 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
976 run: |
977 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
978 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
979 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
980
981 - name: Setup Vite+
982 uses: voidzero-dev/setup-vp@v1
983 with:
984 node-version-file: package.json
985 cache: true
986 run-install: |
987 args:
988 - --filter=@t3tools/scripts...
989 - --filter=@t3tools/oxlint-plugin-t3code...
990
991 - id: update_versions
992 name: Update version strings
993 env:
994 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
995 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
996
997 - name: Format package.json files
998 if: steps.update_versions.outputs.changed == 'true'
999 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
1000
1001 - name: Refresh lockfile
1002 if: steps.update_versions.outputs.changed == 'true'
1003 run: vp install --lockfile-only --ignore-scripts
1004
1005 - name: Commit and push version bump
1006 if: steps.update_versions.outputs.changed == 'true'
1007 shell: bash
1008 env:
1009 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1010 run: |
1011 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
1012 echo "No version changes to commit."
1013 exit 0
1014 fi
1015
1016 git config user.name "${{ steps.app_bot.outputs.name }}"
1017 git config user.email "${{ steps.app_bot.outputs.email }}"
1018
1019 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
1020 git commit -m "chore(release): prepare $RELEASE_TAG"
1021 git push origin HEAD:main
1022
1023 announce_discord:
1024 name: Announce release on Discord
1025 if: |
1026 always() && !cancelled() &&
1027 needs.preflight.result == 'success' &&
1028 needs.relay_public_config.result == 'success' &&
1029 needs.release.result == 'success' &&
1030 needs.deploy_web.result == 'success' &&
1031 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
1032 needs: [preflight, relay_public_config, release, deploy_web, finalize]
1033 runs-on: blacksmith-8vcpu-ubuntu-2404
1034 timeout-minutes: 10
1035 steps:
1036 - name: Checkout
1037 uses: actions/checkout@v6
1038 with:
1039 ref: ${{ needs.preflight.outputs.ref }}
1040
1041 - name: Setup Vite+
1042 uses: voidzero-dev/setup-vp@v1
1043 with:
1044 node-version-file: package.json
1045 cache: true
1046 run-install: |
1047 args:
1048 - --filter=@t3tools/scripts...
1049
1050 - name: Announce prerelease on Discord
1051 if: needs.preflight.outputs.is_prerelease == 'true'
1052 continue-on-error: true
1053 env:
1054 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
1055 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1056 run: |
1057 node scripts/notify-discord-release.ts prerelease \
1058 --role-id "$DISCORD_MENTION_ROLE_ID" \
1059 --release-name "${{ needs.preflight.outputs.release_name }}" \
1060 --release-version "${{ needs.preflight.outputs.version }}" \
1061 --tag "${{ needs.preflight.outputs.tag }}" \
1062 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"
1063
1064 - name: Announce latest release on Discord
1065 if: needs.preflight.outputs.make_latest == 'true'
1066 continue-on-error: true
1067 env:
1068 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
1069 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1070 run: |
1071 node scripts/notify-discord-release.ts latest \
1072 --role-id "$DISCORD_MENTION_ROLE_ID" \
1073 --release-name "${{ needs.preflight.outputs.release_name }}" \
1074 --release-version "${{ needs.preflight.outputs.version }}" \
1075 --tag "${{ needs.preflight.outputs.tag }}" \
1076 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"