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

release.yml

1,471 lines60.8 KB

1name: Release
2​
3on:
4 push:
5 tags:
6 - "v*.*.*"
7 - "!v*-nightly.*"
8 - "!v*-preview.*"
9 schedule:
10 # Avoid minute zero, when GitHub scheduled jobs are busiest.
11 - cron: "8,38 * * * *"
12 workflow_dispatch:
13 inputs:
14 channel:
15 description: "Release channel"
16 required: false
17 default: stable
18 type: choice
19 options:
20 - stable
21 - nightly
22 - preview
23 version:
24 description: "Stable version override (for example 1.2.3). Defaults to the version the latest nightly previewed."
25 required: false
26 type: string
27​
28# Serialize nightlies (scheduled and manual) so overlapping runs cannot build
29# the same commit twice or publish out of order. Stable tag releases get their
30# own group so a nightly never blocks them. Running publishers are never
31# canceled, and queue: max keeps every pending run instead of the default
32# newest-wins single slot, so a queued stable tag can never be silently
33# dropped. Automatic nightlies recheck the release gap after leaving the queue.
34concurrency:
35 group: release-${{ (github.event_name == 'schedule' || inputs.channel == 'nightly' || inputs.channel == 'preview') && 'nightly' || 'stable' }}
36 cancel-in-progress: false
37 queue: max
38​
39permissions:
40 contents: read
41 id-token: none
42​
43jobs:
44 # Picks the commit every later job builds. Nightlies and tag pushes build the
45 # triggering commit. Manual stable releases build the commit of the latest
46 # published nightly, so stable only ever ships a build that nightly users
47 # have already run. Scheduled runs also decide here whether a nightly is due.
48 resolve_commit:
49 name: Resolve release commit
50 runs-on: blacksmith-8vcpu-ubuntu-2404
51 timeout-minutes: 5
52 outputs:
53 ref: ${{ steps.resolve.outputs.ref }}
54 nightly_version: ${{ steps.resolve.outputs.nightly_version }}
55 has_changes: ${{ steps.resolve.outputs.has_changes }}
56 steps:
57 - name: Checkout
58 uses: actions/checkout@v6
59 with:
60 sparse-checkout: .github/scripts
61​
62 - id: resolve
63 name: Resolve release commit
64 uses: actions/github-script@v8
65 env:
66 DISPATCH_CHANNEL: ${{ inputs.channel }}
67 with:
68 script: |
69 const {
70 shouldReleaseNightly,
71 resolveLatestNightlyCommit,
72 } = require('./.github/scripts/check-nightly-release.cjs');
73​
74 if (context.eventName === 'schedule') {
75 core.setOutput('has_changes', await shouldReleaseNightly({ github, context, core }));
76 core.setOutput('ref', context.sha);
77 } else if (context.eventName === 'workflow_dispatch' && process.env.DISPATCH_CHANNEL !== 'nightly' && process.env.DISPATCH_CHANNEL !== 'preview') {
78 const { tag, sha, version } = await resolveLatestNightlyCommit({ github, context, core });
79 core.notice(`Stable release builds ${sha}, the commit shipped by ${tag}.`);
80 core.setOutput('ref', sha);
81 core.setOutput('nightly_version', version);
82 } else {
83 core.setOutput('ref', context.sha);
84 }
85​
86 preflight:
87 name: Preflight
88 needs: [resolve_commit]
89 if: |
90 needs.resolve_commit.result == 'success' &&
91 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
92 runs-on: blacksmith-8vcpu-ubuntu-2404
93 timeout-minutes: 10
94 outputs:
95 release_channel: ${{ steps.release_meta.outputs.release_channel }}
96 version: ${{ steps.release_meta.outputs.version }}
97 tag: ${{ steps.release_meta.outputs.tag }}
98 release_name: ${{ steps.release_meta.outputs.name }}
99 short_sha: ${{ steps.release_meta.outputs.short_sha }}
100 previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
101 cli_dist_tag: ${{ steps.release_meta.outputs.cli_dist_tag }}
102 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
103 make_latest: ${{ steps.release_meta.outputs.make_latest }}
104 ref: ${{ needs.resolve_commit.outputs.ref }}
105 steps:
106 - name: Checkout
107 uses: actions/checkout@v6
108 with:
109 ref: ${{ needs.resolve_commit.outputs.ref }}
110 fetch-depth: 0
111 sparse-checkout: |
112 /*
113 !/.repos/
114 sparse-checkout-cone-mode: false
115​
116 - name: Setup Vite+
117 uses: voidzero-dev/setup-vp@v1
118 with:
119 node-version-file: package.json
120 cache: true
121 run-install: true
122 env:
123 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
124​
125 - id: release_meta
126 name: Resolve release version
127 shell: bash
128 env:
129 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
130 DISPATCH_VERSION: ${{ github.event.inputs.version }}
131 NIGHTLY_VERSION: ${{ needs.resolve_commit.outputs.nightly_version }}
132 NIGHTLY_DATE: ${{ github.run_started_at }}
133 NIGHTLY_SHA: ${{ needs.resolve_commit.outputs.ref }}
134 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
135 run: |
136 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ) ]]; then
137 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
138​
139 node scripts/resolve-nightly-release.ts \
140 --date "$nightly_date" \
141 --run-number "$NIGHTLY_RUN_NUMBER" \
142 --sha "$NIGHTLY_SHA" \
143 --github-output
144​
145 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
146 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
147 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
148 echo "make_latest=false" >> "$GITHUB_OUTPUT"
149 elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "preview" ]]; then
150 # Temporary channel for dogfooding the archive-based CLI runtime.
151 # Same versioning as nightly under its own prerelease identifier.
152 # A preview release is reachable only by downloading it by hand:
153 # it is never published to npm, its desktop builds carry no update
154 # feed, and no updater manifest is attached to the release, so
155 # neither stable nor nightly installs can ever be offered one.
156 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
157​
158 node scripts/resolve-nightly-release.ts \
159 --channel preview \
160 --date "$nightly_date" \
161 --run-number "$NIGHTLY_RUN_NUMBER" \
162 --sha "$NIGHTLY_SHA" \
163 --github-output
164​
165 echo "release_channel=preview" >> "$GITHUB_OUTPUT"
166 echo "cli_dist_tag=" >> "$GITHUB_OUTPUT"
167 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
168 echo "make_latest=false" >> "$GITHUB_OUTPUT"
169 else
170 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
171 raw="${DISPATCH_VERSION:-$NIGHTLY_VERSION}"
172 if [[ -z "$raw" ]]; then
173 echo "workflow_dispatch stable releases need a version input or a published nightly." >&2
174 exit 1
175 fi
176 else
177 raw="${GITHUB_REF_NAME}"
178 fi
179​
180 version="${raw#v}"
181 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
182 echo "Invalid release version: $raw" >&2
183 exit 1
184 fi
185​
186 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
187 echo "version=$version" >> "$GITHUB_OUTPUT"
188 echo "tag=v$version" >> "$GITHUB_OUTPUT"
189 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
190 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
191 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
192 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
193 echo "make_latest=true" >> "$GITHUB_OUTPUT"
194 else
195 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
196 echo "make_latest=false" >> "$GITHUB_OUTPUT"
197 fi
198 fi
199​
200 - id: previous_tag
201 name: Resolve previous release tag
202 run: |
203 node scripts/resolve-previous-release-tag.ts \
204 --channel "${{ steps.release_meta.outputs.release_channel }}" \
205 --current-tag "${{ steps.release_meta.outputs.tag }}" \
206 --github-output
207​
208 # Share only the verification results, not the large registry metadata cache.
209 - name: Upload dependency verification
210 continue-on-error: true
211 uses: actions/upload-artifact@v7
212 with:
213 name: release-dependency-verification
214 path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
215​
216 quality:
217 name: Release quality checks
218 needs: [preflight]
219 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
220 runs-on: blacksmith-8vcpu-ubuntu-2404
221 timeout-minutes: 10
222 steps:
223 - name: Checkout
224 uses: actions/checkout@v6
225 with:
226 ref: ${{ needs.preflight.outputs.ref }}
227 sparse-checkout: |
228 /*
229 !/.repos/
230 sparse-checkout-cone-mode: false
231​
232 - name: Setup Vite+
233 uses: voidzero-dev/setup-vp@v1
234 with:
235 node-version-file: package.json
236 cache: true
237 run-install: true
238​
239 - name: Ensure Electron runtime is installed
240 run: vp run --filter @t3tools/desktop ensure:electron
241​
242 - name: Check
243 run: vp check
244​
245 - name: Typecheck
246 run: vp run typecheck
247​
248 - uses: ./.github/actions/setup-apt-mirrors
249​
250 - name: Install browser secret helper build libraries
251 run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
252​
253 - name: Test
254 run: vp run test
255​
256 relay_public_config:
257 name: Resolve T3 Connect public config
258 # Consumes only the release commit, not preflight's resolved version, so it
259 # runs alongside preflight instead of after it. The condition mirrors preflight's.
260 needs: [resolve_commit]
261 if: |
262 needs.resolve_commit.result == 'success' &&
263 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
264 runs-on: blacksmith-8vcpu-ubuntu-2404
265 timeout-minutes: 5
266 environment:
267 name: production
268 outputs:
269 clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
270 clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
271 clerk_cli_oauth_client_id: ${{ steps.public_config.outputs.clerk_cli_oauth_client_id }}
272 relay_url: ${{ steps.public_config.outputs.relay_url }}
273 env:
274 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
275 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
276 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
277 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
278 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
279 CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }}
280 CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }}
281 steps:
282 - name: Checkout
283 uses: actions/checkout@v6
284 with:
285 ref: ${{ needs.resolve_commit.outputs.ref }}
286 sparse-checkout: |
287 /*
288 !/.repos/
289 sparse-checkout-cone-mode: false
290​
291 - name: Setup Vite+
292 uses: voidzero-dev/setup-vp@v1
293 with:
294 node-version-file: package.json
295 cache: true
296 run-install: |
297 args:
298 - --filter=t3code-relay...
299​
300 - id: relay_state
301 name: Read production relay tracing config
302 shell: bash
303 run: |
304 vp run --filter t3code-relay deploy \
305 --stage prod \
306 --read-state \
307 --github-output \
308 --github-env-file "$RUNNER_TEMP/relay-client-tracing.env"
309​
310 - name: Upload relay client tracing config
311 uses: actions/upload-artifact@v7
312 with:
313 name: relay-client-tracing-config
314 path: ${{ runner.temp }}/relay-client-tracing.env
315 if-no-files-found: error
316 retention-days: 1
317​
318 - id: public_config
319 name: Resolve production relay public config
320 shell: bash
321 run: |
322 set -euo pipefail
323​
324 relay_domain="${RELAY_DOMAIN:-}"
325 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
326 relay_domain="relay.$RELAY_API_ZONE_NAME"
327 fi
328 required=(
329 relay_domain
330 CLERK_PUBLISHABLE_KEY
331 CLERK_JWT_TEMPLATE
332 CLERK_CLI_OAUTH_CLIENT_ID
333 )
334 missing=()
335 for name in "${required[@]}"; do
336 if [[ -z "${!name:-}" ]]; then
337 missing+=("$name")
338 fi
339 done
340 if (( ${#missing[@]} > 0 )); then
341 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
342 exit 1
343 fi
344​
345 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
346 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
347 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
348 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
349​
350 # node-pty publishes no Linux prebuilt and the WSL backend runs under the
351 # distro's own (Linux) Node, which can't load the Windows/Electron binary. We
352 # build the Linux pty.node here, on Linux, and hand it to the Windows packaging
353 # job — the Windows artifact then ships a ready WSL backend binary with no
354 # cross-compiling and no first-launch compiler/node-gyp/network on the user's
355 # machine. node-pty is N-API, so one binary works across all WSL Node versions.
356 build_wsl_node_pty:
357 name: Build WSL node-pty (linux-x64)
358 # Same gating as relay_public_config: only the release commit is needed, so
359 # this runs alongside preflight. See the condition comment there.
360 needs: [resolve_commit]
361 if: |
362 needs.resolve_commit.result == 'success' &&
363 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
364 runs-on: blacksmith-8vcpu-ubuntu-2404
365 timeout-minutes: 15
366 steps:
367 - name: Checkout
368 uses: actions/checkout@v6
369 with:
370 ref: ${{ needs.resolve_commit.outputs.ref }}
371 sparse-checkout: |
372 /*
373 !/.repos/
374 sparse-checkout-cone-mode: false
375​
376 - name: Setup Vite+
377 uses: voidzero-dev/setup-vp@v1
378 with:
379 node-version-file: package.json
380 cache: true
381 run-install: |
382 args:
383 - --filter=t3...
384​
385 - name: Build node-pty linux-x64 prebuild
386 shell: bash
387 run: |
388 set -euo pipefail
389 # Resolve node-pty from apps/server (where it's a dependency) and build
390 # its native binary from source for Linux. node-addon-api resolves from
391 # node-pty's own dependency tree, so node-gyp has everything it needs.
392 pty_pkg="$(node -e "console.log(require.resolve('node-pty/package.json', { paths: ['$GITHUB_WORKSPACE/apps/server'] }))")"
393 pty_dir="$(dirname "$pty_pkg")"
394 ( cd "$pty_dir" && npx --yes node-gyp rebuild )
395 mkdir -p wsl-prebuild
396 cp "$pty_dir/build/Release/pty.node" wsl-prebuild/pty.node
397 file wsl-prebuild/pty.node
398​
399 - name: Upload node-pty linux-x64 prebuild
400 uses: actions/upload-artifact@v7
401 with:
402 name: wsl-node-pty-x64
403 path: wsl-prebuild/pty.node
404 if-no-files-found: error
405​
406 build:
407 name: Build ${{ matrix.label }}
408 # build_wsl_node_pty stays in `needs` so it runs first and its artifact is
409 # available to download, but only the Windows matrix entry consumes it. We
410 # therefore gate the job on preflight + relay (must succeed) WITHOUT requiring
411 # build_wsl_node_pty, so a failed Linux prebuild doesn't skip the macOS/Linux
412 # builds. `!cancelled()` (not `!failure()`) lets the job run even when
413 # build_wsl_node_pty failed; the Windows-only download step below then fails
414 # that single platform if the prebuild is missing.
415 needs: [preflight, relay_public_config, build_wsl_node_pty]
416 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
417 runs-on: ${{ matrix.runner }}
418 timeout-minutes: 30
419 env:
420 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
421 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
422 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
423 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
424 strategy:
425 fail-fast: false
426 matrix:
427 include:
428 # cli_archive: whether the job also builds the self-contained CLI
429 # archive. The executable is built on the runner's own Node, so only
430 # native runners qualify. macOS x64 has no native runner: a
431 # cross-built executable crashed under Rosetta in the smoke test and
432 # cannot be verified on real x64 hardware in CI, so it is skipped
433 # until it can be.
434 - label: macOS arm64
435 runner: blacksmith-12vcpu-macos-26
436 platform: mac
437 target: dmg
438 arch: arm64
439 rust_target: aarch64-apple-darwin
440 resource_key: darwin-arm64
441 cli_archive: true
442 - label: macOS x64
443 runner: blacksmith-12vcpu-macos-26
444 platform: mac
445 target: dmg
446 arch: x64
447 rust_target: x86_64-apple-darwin
448 resource_key: darwin-x64
449 cli_archive: false
450 - label: Linux x64
451 runner: blacksmith-32vcpu-ubuntu-2404
452 platform: linux
453 target: AppImage
454 arch: x64
455 rust_target: x86_64-unknown-linux-gnu
456 resource_key: linux-x64
457 cli_archive: true
458 - label: Windows x64
459 runner: blacksmith-32vcpu-windows-2025
460 platform: win
461 target: nsis
462 arch: x64
463 rust_target: x86_64-pc-windows-msvc
464 resource_key: win32-x64
465 cli_archive: true
466 # - label: Windows arm64
467 # runner: windows-11-arm
468 # platform: win
469 # target: nsis
470 # arch: arm64
471 steps:
472 - name: Checkout
473 uses: actions/checkout@v6
474 with:
475 ref: ${{ needs.preflight.outputs.ref }}
476 sparse-checkout: |
477 /*
478 !/.repos/
479 sparse-checkout-cone-mode: false
480​
481 - name: Setup Vite+
482 uses: voidzero-dev/setup-vp@v1
483 with:
484 node-version-file: package.json
485 cache: ${{ matrix.platform != 'win' }}
486 run-install: false
487​
488 - name: Resolve Windows package cache path
489 if: matrix.platform == 'win'
490 id: package_cache_path
491 shell: pwsh
492 run: '"path=$(vp pm cache dir)" >> $env:GITHUB_OUTPUT'
493​
494 - name: Cache Windows packages
495 if: matrix.platform == 'win'
496 uses: actions/cache@v6
497 with:
498 path: ${{ steps.package_cache_path.outputs.path }}
499 key: windows-release-packages-v1-${{ matrix.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
500​
501 # pnpm checks the lockfile and policy before reusing this result. A missing
502 # artifact leaves the cache empty, so installation runs the checks again.
503 - name: Download dependency verification
504 continue-on-error: true
505 uses: actions/download-artifact@v8
506 with:
507 name: release-dependency-verification
508 path: ${{ runner.temp }}/pnpm-metadata
509​
510 - name: Install desktop dependencies
511 env:
512 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
513 run: vp install --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
514​
515 - name: Cache resource monitor
516 id: resource_monitor_cache
517 uses: actions/cache@v6
518 with:
519 path: native/resource-monitor/target/${{ matrix.rust_target }}/release/t3-resource-monitor${{ matrix.platform == 'win' && '.exe' || '' }}
520 key: resource-monitor-${{ matrix.rust_target }}-${{ hashFiles('native/resource-monitor/Cargo.lock', 'native/resource-monitor/Cargo.toml', 'native/resource-monitor/src/**') }}
521​
522 - name: Cache Linux capture helpers
523 if: matrix.platform == 'linux'
524 id: capture_helper_cache
525 uses: actions/cache@v6
526 with:
527 path: |
528 native/kde-snap-shot/target/${{ matrix.rust_target }}/release/t3-kde-snap-shot
529 native/hyprland-snap-shot/target/${{ matrix.rust_target }}/release/t3-hyprland-snap-shot
530 key: linux-capture-helpers-${{ matrix.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/**') }}
531​
532 - name: Setup Rust
533 if: steps.resource_monitor_cache.outputs.cache-hit != 'true' || (matrix.platform == 'linux' && steps.capture_helper_cache.outputs.cache-hit != 'true')
534 uses: dtolnay/rust-toolchain@stable
535 with:
536 targets: ${{ matrix.rust_target }}
537​
538 - name: Download relay client tracing config
539 uses: actions/download-artifact@v8
540 with:
541 name: relay-client-tracing-config
542 path: ${{ runner.temp }}/relay-client-tracing
543​
544 - name: Load relay client tracing config
545 shell: bash
546 run: |
547 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
548 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
549 echo "::add-mask::$tracing_token"
550 cat "$config_path" >> "$GITHUB_ENV"
551​
552 - name: Align package versions to release version
553 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
554​
555 - name: Download WSL node-pty prebuild
556 if: matrix.platform == 'win'
557 uses: actions/download-artifact@v7
558 with:
559 name: wsl-node-pty-x64
560 path: wsl-prebuild
561​
562 - name: Install Spectre-mitigated MSVC libs
563 if: matrix.platform == 'win'
564 shell: pwsh
565 run: |
566 $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
567 $installPath = & $vswhere -products * -latest -property installationPath
568 $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
569 $proc = Start-Process -FilePath $setupExe `
570 -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
571 "Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre", "--quiet", "--norestart" `
572 -Wait -PassThru -NoNewWindow
573 if ($null -eq $proc -or $proc.ExitCode -ne 0) {
574 $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
575 Write-Error "Visual Studio Installer failed with exit code $code"
576 exit $code
577 }
578​
579 - uses: ./.github/actions/setup-apt-mirrors
580 if: matrix.platform == 'linux'
581​
582 - name: Install Linux desktop build libraries
583 if: matrix.platform == 'linux'
584 shell: bash
585 run: |
586 sudo apt-get update
587 sudo apt-get install -y libsecret-1-dev pkg-config
588 if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
589 sudo apt-get install -y imagemagick
590 fi
591​
592 if command -v magick >/dev/null 2>&1; then
593 magick -version
594 else
595 convert -version
596 fi
597​
598 - name: Prepare Azure Trusted Signing
599 if: matrix.platform == 'win'
600 shell: pwsh
601 env:
602 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
603 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
604 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
605 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
606 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
607 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
608 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
609 run: |
610 $ErrorActionPreference = "Stop"
611​
612 $requiredSecrets = @(
613 $env:AZURE_TENANT_ID,
614 $env:AZURE_CLIENT_ID,
615 $env:AZURE_CLIENT_SECRET,
616 $env:AZURE_TRUSTED_SIGNING_ENDPOINT,
617 $env:AZURE_TRUSTED_SIGNING_ACCOUNT_NAME,
618 $env:AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME,
619 $env:AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
620 )
621 if ($requiredSecrets | Where-Object { [string]::IsNullOrWhiteSpace($_) }) {
622 Write-Host "Azure Trusted Signing disabled; skipping TrustedSigning module preparation."
623 exit 0
624 }
625​
626 try {
627 Install-PackageProvider `
628 -Name NuGet `
629 -MinimumVersion 2.8.5.201 `
630 -Force `
631 -Scope CurrentUser `
632 -ErrorAction Stop
633 } catch {
634 Write-Warning "Could not bootstrap NuGet package provider. Continuing because the runner may already have a usable provider. $($_.Exception.Message)"
635 }
636​
637 Install-Module `
638 -Name TrustedSigning `
639 -MinimumVersion 0.5.0 `
640 -Force `
641 -AllowClobber `
642 -Repository PSGallery `
643 -Scope CurrentUser `
644 -ErrorAction Stop
645​
646 Import-Module TrustedSigning -MinimumVersion 0.5.0 -Force
647 Get-Command Invoke-TrustedSigning -ErrorAction Stop
648​
649 $moduleRoots = @(
650 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "PowerShell", "Modules"),
651 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "WindowsPowerShell", "Modules"),
652 [System.IO.Path]::Combine($env:ProgramFiles, "PowerShell", "Modules"),
653 [System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules")
654 )
655 $modulePathEntries = @($moduleRoots + ($env:PSModulePath -split ";")) |
656 Where-Object { $_ -and (Test-Path $_) } |
657 Select-Object -Unique
658 "PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
659​
660 - name: Build desktop artifact
661 shell: bash
662 env:
663 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
664 T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: ${{ steps.resource_monitor_cache.outputs.cache-hit == 'true' }}
665 T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
666 CSC_LINK: ${{ secrets.CSC_LINK }}
667 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
668 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
669 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
670 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
671 APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
672 MACOS_PROVISIONING_PROFILE: ${{ secrets.MACOS_PROVISIONING_PROFILE }}
673 T3CODE_CLERK_PASSKEY_RP_DOMAINS: ${{ vars.CLERK_PASSKEY_RP_DOMAINS }}
674 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
675 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
676 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
677 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
678 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
679 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
680 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
681 run: |
682 args=(
683 --platform "${{ matrix.platform }}"
684 --target "${{ matrix.target }}"
685 --arch "${{ matrix.arch }}"
686 --build-version "${{ needs.preflight.outputs.version }}"
687 --verbose
688 )
689​
690 has_all() {
691 for value in "$@"; do
692 if [[ -z "$value" ]]; then
693 return 1
694 fi
695 done
696 return 0
697 }
698​
699 if [[ "${{ matrix.platform }}" == "mac" ]]; then
700 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
701 if ! has_all "$APPLE_TEAM_ID" "$MACOS_PROVISIONING_PROFILE"; then
702 echo "macOS signing is configured, but APPLE_TEAM_ID or MACOS_PROVISIONING_PROFILE is missing." >&2
703 exit 1
704 fi
705​
706 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
707 printf '%s' "$APPLE_API_KEY" > "$key_path"
708 export APPLE_API_KEY="$key_path"
709​
710 profile_path="$RUNNER_TEMP/t3code.provisionprofile"
711 printf '%s' "$MACOS_PROVISIONING_PROFILE" | base64 -D > "$profile_path"
712 security cms -D -i "$profile_path" >/dev/null
713 export T3CODE_APPLE_TEAM_ID="$APPLE_TEAM_ID"
714 export T3CODE_MACOS_PROVISIONING_PROFILE="$profile_path"
715​
716 echo "macOS signing enabled."
717 args+=(--signed)
718 else
719 echo "macOS signing disabled (missing one or more Apple signing secrets)."
720 fi
721 elif [[ "${{ matrix.platform }}" == "win" ]]; then
722 # Bundle the Linux node-pty binary built by the build_wsl_node_pty job
723 # so the packaged WSL backend ships a ready binary (no first-launch
724 # compile). Required for a working WSL backend on Windows.
725 args+=(--wsl-prebuild "$GITHUB_WORKSPACE/wsl-prebuild/pty.node")
726 if has_all \
727 "$AZURE_TENANT_ID" \
728 "$AZURE_CLIENT_ID" \
729 "$AZURE_CLIENT_SECRET" \
730 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
731 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
732 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
733 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
734 echo "Windows signing enabled (Azure Trusted Signing)."
735 args+=(--signed)
736 else
737 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
738 fi
739 else
740 echo "Signing disabled for ${{ matrix.platform }}."
741 fi
742​
743 vp run dist:desktop:artifact "${args[@]}"
744​
745 # The single-executable is built with a Node that supports --build-sea
746 # (25.7+); the repo itself stays on the engines.node version. It always
747 # injects into the runner's own Node: tsdown's cross-target download path
748 # runs `tar` on a drive-letter path on Windows, which GNU tar reads as a
749 # remote host, and a cross-built macOS binary cannot be smoke-tested.
750 - name: Build CLI single-executable
751 if: matrix.cli_archive
752 shell: bash
753 env:
754 # The exact version, not a major: vp downloads it from nodejs.org/dist on
755 # the runner, and only exact versions have a dist directory. Keep in
756 # step with SEA_NODE_VERSION in apps/server/vite.config.ts.
757 VP_NODE_VERSION: "26.8.2"
758 run: node apps/server/scripts/cli.ts build-exe --verbose
759​
760 - name: Import macOS signing certificate for the CLI archive
761 if: matrix.cli_archive && matrix.platform == 'mac'
762 shell: bash
763 env:
764 CSC_LINK: ${{ secrets.CSC_LINK }}
765 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
766 run: |
767 set -euo pipefail
768 if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" ]]; then
769 echo "macOS CLI signing disabled (missing CSC_LINK); the archive is signed ad hoc."
770 exit 0
771 fi
772 keychain="$RUNNER_TEMP/t3-cli-signing.keychain-db"
773 keychain_password="$(openssl rand -hex 16)"
774 cert_path="$RUNNER_TEMP/t3-cli-signing.p12"
775 printf '%s' "$CSC_LINK" | base64 --decode > "$cert_path"
776 security create-keychain -p "$keychain_password" "$keychain"
777 security set-keychain-settings -lut 21600 "$keychain"
778 security unlock-keychain -p "$keychain_password" "$keychain"
779 security import "$cert_path" -k "$keychain" -P "$CSC_KEY_PASSWORD" -T /usr/bin/codesign
780 security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain" >/dev/null
781 security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
782 identity="$(security find-identity -v -p codesigning "$keychain" | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -n 1)"
783 if [[ -z "$identity" ]]; then
784 echo "No Developer ID Application identity found in CSC_LINK." >&2
785 exit 1
786 fi
787 echo "::add-mask::$keychain_password"
788 echo "T3CODE_CLI_MAC_SIGN_IDENTITY=$identity" >> "$GITHUB_ENV"
789 echo "macOS CLI signing enabled."
790​
791 - name: Stage resource monitor for the CLI archive
792 if: matrix.cli_archive
793 shell: bash
794 run: |
795 set -euo pipefail
796 binary_name="t3-resource-monitor"
797 if [[ "${{ matrix.platform }}" == "win" ]]; then
798 binary_name="${binary_name}.exe"
799 fi
800 target_dir="$RUNNER_TEMP/cli-resource-monitor/${{ matrix.resource_key }}"
801 mkdir -p "$target_dir"
802 cp "native/resource-monitor/target/${{ matrix.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
803​
804 - name: Build CLI archive
805 if: matrix.cli_archive
806 shell: bash
807 env:
808 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
809 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
810 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
811 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
812 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
813 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
814 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
815 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
816 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
817 run: |
818 set -euo pipefail
819 if [[ "${{ matrix.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then
820 key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"
821 printf '%s' "$APPLE_API_KEY" > "$key_path"
822 export APPLE_API_KEY="$key_path"
823 fi
824 node scripts/build-cli-archive.ts \
825 --platform "${{ matrix.platform }}" \
826 --arch "${{ matrix.arch }}" \
827 --version "${{ needs.preflight.outputs.version }}" \
828 --resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \
829 --output-dir release-cli
830​
831 - name: Smoke-test CLI archive
832 if: matrix.cli_archive
833 shell: bash
834 run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ needs.preflight.outputs.version }}"
835​
836 - name: Upload CLI archive
837 if: matrix.cli_archive
838 uses: actions/upload-artifact@v7
839 with:
840 name: cli-${{ matrix.platform }}-${{ matrix.arch }}
841 path: release-cli/*
842 if-no-files-found: error
843​
844 - name: Collect release assets
845 shell: bash
846 run: |
847 set -euo pipefail
848 mkdir -p release-publish
849​
850 shopt -s nullglob
851 patterns=(
852 "release/*.dmg"
853 "release/*.zip"
854 "release/*.AppImage"
855 "release/*.exe"
856 )
857 # Preview builds have no publish config, so electron-builder writes
858 # no feed manifest for them, but it still emits blockmaps beside the
859 # installers. Neither belongs on a release no updater may follow.
860 if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
861 patterns+=("release/*.blockmap" "release/*.yml")
862 fi
863 for pattern in "${patterns[@]}"; do
864 for file in $pattern; do
865 cp "$file" release-publish/
866 done
867 done
868​
869 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
870 shopt -s nullglob
871 for manifest in release-publish/*-mac.yml; do
872 mv "$manifest" "${manifest%.yml}-${{ matrix.arch }}.yml"
873 done
874 fi
875​
876 # Enable if Windows arm64 builds are enabled.
877 # Windows updater metadata is channel-specific (for example
878 # "latest.yml" or "nightly.yml"). Suffix each per-arch copy so the
879 # release job can merge matching arm64/x64 manifests back into one
880 # canonical manifest per channel.
881 # if [[ "${{ matrix.platform }}" == "win" ]]; then
882 # shopt -s nullglob
883 # for manifest in release-publish/*.yml; do
884 # mv "$manifest" "${manifest%.yml}-win-${{ matrix.arch }}.yml"
885 # done
886 # fi
887​
888 - name: Collect resource monitor
889 shell: bash
890 run: |
891 set -euo pipefail
892 binary_name="t3-resource-monitor"
893 if [[ "${{ matrix.platform }}" == "win" ]]; then
894 binary_name="${binary_name}.exe"
895 fi
896 source_path="native/resource-monitor/target/${{ matrix.rust_target }}/release/${binary_name}"
897 target_dir="resource-monitor-publish/${{ matrix.resource_key }}"
898 mkdir -p "$target_dir"
899 cp "$source_path" "$target_dir/$binary_name"
900​
901 - name: Upload build artifacts
902 uses: actions/upload-artifact@v7
903 with:
904 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
905 path: release-publish/*
906 if-no-files-found: error
907​
908 - name: Upload resource monitor
909 uses: actions/upload-artifact@v7
910 with:
911 name: resource-monitor-${{ matrix.resource_key }}
912 path: resource-monitor-publish/${{ matrix.resource_key }}/*
913 if-no-files-found: error
914​
915 # Preview releases never reach npm: the archive on the GitHub Release is the
916 # only way to obtain one, so no dist-tag can ever resolve to a preview build.
917 publish_cli:
918 name: Publish CLI to npm
919 needs: [preflight, relay_public_config, quality, build]
920 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.quality.result == 'success' && needs.build.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
921 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
922 timeout-minutes: 10
923 permissions:
924 contents: read
925 id-token: write
926 env:
927 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
928 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
929 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
930 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
931 steps:
932 - name: Checkout
933 uses: actions/checkout@v6
934 with:
935 ref: ${{ needs.preflight.outputs.ref }}
936 sparse-checkout: |
937 /*
938 !/.repos/
939 sparse-checkout-cone-mode: false
940​
941 - name: Setup Vite+
942 uses: voidzero-dev/setup-vp@v1
943 with:
944 node-version-file: package.json
945 cache: true
946 run-install: |
947 args:
948 - --filter=t3...
949 - --filter=@t3tools/web...
950 - --filter=@t3tools/scripts...
951​
952 - name: Download relay client tracing config
953 uses: actions/download-artifact@v8
954 with:
955 name: relay-client-tracing-config
956 path: ${{ runner.temp }}/relay-client-tracing
957​
958 - name: Load relay client tracing config
959 shell: bash
960 run: |
961 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
962 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
963 echo "::add-mask::$tracing_token"
964 cat "$config_path" >> "$GITHUB_ENV"
965​
966 - name: Align package versions to release version
967 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
968​
969 # The t3 build task depends on @t3tools/web#build, so the web client is
970 # built (once) as part of this step.
971 - name: Build CLI package
972 run: vp run --filter t3 build
973​
974 - name: Download resource monitors
975 uses: actions/download-artifact@v8
976 with:
977 pattern: resource-monitor-*
978 path: ${{ runner.temp }}/resource-monitors
979​
980 - name: Bundle resource monitors into CLI package
981 shell: bash
982 run: |
983 set -euo pipefail
984 for artifact_dir in "$RUNNER_TEMP"/resource-monitors/resource-monitor-*; do
985 resource_key="${artifact_dir##*/resource-monitor-}"
986 target_dir="apps/server/dist/resource-monitor/${resource_key}"
987 mkdir -p "$target_dir"
988 cp "$artifact_dir"/t3-resource-monitor* "$target_dir/"
989 chmod +x "$target_dir"/t3-resource-monitor 2>/dev/null || true
990 done
991​
992 - name: Publish CLI package
993 run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
994​
995 release:
996 name: Publish GitHub Release
997 needs: [preflight, build, publish_cli]
998 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' && (needs.publish_cli.result == 'success' || (needs.preflight.outputs.release_channel == 'preview' && needs.publish_cli.result == 'skipped')) }}
999 runs-on: blacksmith-8vcpu-ubuntu-2404
1000 timeout-minutes: 30
1001 permissions:
1002 contents: write
1003 steps:
1004 - name: Checkout
1005 uses: actions/checkout@v6
1006 with:
1007 ref: ${{ needs.preflight.outputs.ref }}
1008 sparse-checkout: |
1009 /*
1010 !/.repos/
1011 sparse-checkout-cone-mode: false
1012​
1013 - name: Setup Vite+
1014 uses: voidzero-dev/setup-vp@v1
1015 with:
1016 node-version-file: package.json
1017 cache: true
1018 run-install: |
1019 args:
1020 - --filter=@t3tools/scripts...
1021​
1022 - name: Download all desktop artifacts
1023 uses: actions/download-artifact@v8
1024 with:
1025 pattern: desktop-*
1026 merge-multiple: true
1027 path: release-assets
1028​
1029 - name: Download all CLI archives
1030 uses: actions/download-artifact@v8
1031 with:
1032 pattern: cli-*
1033 merge-multiple: true
1034 path: release-assets
1035​
1036 # Installers verify archives against this file, so it is written from the
1037 # signed bytes that get uploaded, never from an earlier stage.
1038 - name: Write CLI archive checksums
1039 shell: bash
1040 run: |
1041 set -euo pipefail
1042 cd release-assets
1043 shopt -s nullglob
1044 archives=(t3-*.tar.gz t3-*.zip)
1045 if [[ ${#archives[@]} -eq 0 ]]; then
1046 echo "No CLI archives were produced." >&2
1047 exit 1
1048 fi
1049 sha256sum "${archives[@]}" > SHA256SUMS
1050 cat SHA256SUMS
1051​
1052 # The desktop build omits the publish config for preview versions, so
1053 # electron-builder emits no updater manifests for them. Refuse to publish
1054 # if one shows up anyway: a `latest*.yml` or `nightly*.yml` on a preview
1055 # release is what would let a stable or nightly install update onto it.
1056 - name: Refuse updater metadata on preview releases
1057 if: needs.preflight.outputs.release_channel == 'preview'
1058 shell: bash
1059 run: |
1060 set -euo pipefail
1061 shopt -s nullglob extglob
1062 # builder-debug.yml is electron-builder's config dump, not a feed.
1063 updater_files=(release-assets/!(builder-debug).yml release-assets/*.blockmap)
1064 if [[ ${#updater_files[@]} -ne 0 ]]; then
1065 printf 'Preview releases must not carry updater metadata, found: %s\n' "${updater_files[*]}" >&2
1066 exit 1
1067 fi
1068​
1069 - name: Merge macOS updater manifests
1070 if: needs.preflight.outputs.release_channel != 'preview'
1071 run: |
1072 shopt -s nullglob
1073 for x64_manifest in release-assets/*-mac-x64.yml; do
1074 arm64_manifest="${x64_manifest%-x64.yml}.yml"
1075 if [[ -f "$arm64_manifest" ]]; then
1076 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
1077 rm -f "$x64_manifest"
1078 fi
1079 done
1080​
1081 # Updater manifests and blockmaps are what electron-updater consumes.
1082 # They are only listed for channels an updater is meant to follow.
1083 - id: release_files
1084 name: Resolve release asset list
1085 shell: bash
1086 run: |
1088 echo 'files<<EOF'
1089 echo 'release-assets/*.dmg'
1090 echo 'release-assets/*.zip'
1091 echo 'release-assets/*.AppImage'
1092 echo 'release-assets/*.exe'
1093 if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
1094 echo 'release-assets/*.blockmap'
1095 echo 'release-assets/*.yml'
1096 fi
1097 echo 'release-assets/*.tar.gz'
1098 echo 'release-assets/SHA256SUMS'
1099 echo 'EOF'
1100 } >> "$GITHUB_OUTPUT"
1101​
1102 # A preview release gets a warning instead of generated notes. Generated
1103 # notes would list every commit since the previous preview, which is
1104 # unmerged branch history no one should read as a changelog, and would
1105 # make the release look like any other build to someone browsing the
1106 # releases page.
1107 - name: Write preview release notes
1108 if: needs.preflight.outputs.release_channel == 'preview'
1109 shell: bash
1110 run: |
1111 cat > release-notes.md <<'EOF'
1112 > [!WARNING]
1113 > **This is a preview build. Do not install it unless you know exactly why you are here.**
1115 > Preview builds are cut by maintainers from unreleased branches to exercise the release pipeline. They can be broken, receive no fixes, are never offered as updates, and are not supported. If you want T3 Code, install the [latest release](https://github.com/pingdotgg/t3code/releases/latest) or a nightly instead.
1116​
1117 Built from `${{ needs.preflight.outputs.ref }}`.
1118 EOF
1119​
1120 - name: Publish release
1121 if: needs.preflight.outputs.previous_tag != ''
1122 uses: softprops/action-gh-release@v3
1123 with:
1124 tag_name: ${{ needs.preflight.outputs.tag }}
1125 target_commitish: ${{ needs.preflight.outputs.ref }}
1126 name: ${{ needs.preflight.outputs.release_name }}
1127 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
1128 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
1129 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
1130 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
1131 make_latest: ${{ needs.preflight.outputs.make_latest }}
1132 files: ${{ steps.release_files.outputs.files }}
1133 fail_on_unmatched_files: true
1134 token: ${{ github.token }}
1135​
1136 - name: Publish first release
1137 if: needs.preflight.outputs.previous_tag == ''
1138 uses: softprops/action-gh-release@v3
1139 with:
1140 tag_name: ${{ needs.preflight.outputs.tag }}
1141 target_commitish: ${{ needs.preflight.outputs.ref }}
1142 name: ${{ needs.preflight.outputs.release_name }}
1143 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
1144 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
1145 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
1146 make_latest: ${{ needs.preflight.outputs.make_latest }}
1147 files: ${{ steps.release_files.outputs.files }}
1148 fail_on_unmatched_files: true
1149 token: ${{ github.token }}
1150​
1151 publish_aur:
1152 name: Publish AUR package
1153 needs: [preflight, release]
1154 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1155 uses: ./.github/workflows/publish-aur.yml
1156 with:
1157 release_tag: ${{ needs.preflight.outputs.tag }}
1158 secrets:
1159 AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
1160​
1161 deploy_web:
1162 name: Deploy hosted web app
1163 needs: [preflight, relay_public_config, release]
1164 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1165 runs-on: blacksmith-8vcpu-ubuntu-2404
1166 timeout-minutes: 10
1167 env:
1168 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
1169 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
1170 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
1171 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
1172 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1173 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1174 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1175 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1176 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
1177 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
1178 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1179 steps:
1180 - name: Checkout
1181 uses: actions/checkout@v6
1182 with:
1183 ref: ${{ needs.preflight.outputs.ref }}
1184 sparse-checkout: |
1185 /*
1186 !/.repos/
1187 sparse-checkout-cone-mode: false
1188​
1189 - name: Setup Vite+
1190 uses: voidzero-dev/setup-vp@v1
1191 with:
1192 node-version-file: package.json
1193 cache: true
1194 run-install: |
1195 args:
1196 - --filter=@t3tools/scripts...
1197 - --filter=@t3tools/web...
1198​
1199 - name: Download relay client tracing config
1200 uses: actions/download-artifact@v8
1201 with:
1202 name: relay-client-tracing-config
1203 path: ${{ runner.temp }}/relay-client-tracing
1204​
1205 - name: Load relay client tracing config
1206 shell: bash
1207 run: |
1208 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
1209 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
1210 echo "::add-mask::$tracing_token"
1211 cat "$config_path" >> "$GITHUB_ENV"
1212​
1213 - name: Align package versions to release version
1214 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
1215​
1216 - name: Refresh release lockfile
1217 run: vp install --lockfile-only --ignore-scripts
1218​
1219 - name: Deploy and alias channel
1220 shell: bash
1221 run: |
1222 set -euo pipefail
1223​
1224 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
1225 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
1226 exit 1
1227 fi
1228​
1229 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1230 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
1231 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
1232 router_domain="${router_url#http://}"
1233 router_domain="${router_domain#https://}"
1234 router_domain="${router_domain%%/*}"
1235​
1236 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1237 channel_domain="$latest_domain"
1238 channel_name="latest"
1239 else
1240 channel_domain="$nightly_domain"
1241 channel_name="nightly"
1242 fi
1243​
1244 vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1245 vercel_scope_args=(--scope "$vercel_scope")
1246​
1247 echo "Deploying hosted web app for $channel_name channel."
1248 deployment_url="$(
1249 vp dlx vercel@53.1.1 deploy \
1250 --archive=tgz \
1251 --prod \
1252 --skip-domain \
1253 --yes \
1254 --token "$VERCEL_TOKEN" \
1255 "${vercel_scope_args[@]}" \
1256 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
1257 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
1258 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
1259 --build-env "T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=${T3CODE_CLERK_CLI_OAUTH_CLIENT_ID:-}" \
1260 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
1261 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
1262 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
1263 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
1264 --build-env "VITE_HOSTED_APP_URL=$router_url" \
1265 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
1266 )"
1267​
1268 echo "Aliasing $deployment_url to $channel_domain."
1269 vp dlx vercel@53.1.1 alias set "$deployment_url" "$channel_domain" \
1270 --token "$VERCEL_TOKEN" \
1271 "${vercel_scope_args[@]}"
1272​
1273 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
1274 echo "Aliasing $deployment_url to router domain $router_domain."
1275 vp dlx vercel@53.1.1 alias set "$deployment_url" "$router_domain" \
1276 --token "$VERCEL_TOKEN" \
1277 "${vercel_scope_args[@]}"
1278 fi
1279​
1280 deploy_marketing:
1281 name: Deploy marketing site
1282 needs: [preflight, release]
1283 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1284 runs-on: blacksmith-8vcpu-ubuntu-2404
1285 timeout-minutes: 10
1286 env:
1287 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1288 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1289 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1290 steps:
1291 - name: Checkout
1292 uses: actions/checkout@v6
1293 with:
1294 ref: ${{ needs.preflight.outputs.ref }}
1295 sparse-checkout: |
1296 /*
1297 !/.repos/
1298 sparse-checkout-cone-mode: false
1299​
1300 - name: Setup Vite+
1301 uses: voidzero-dev/setup-vp@v1
1302 with:
1303 node-version-file: package.json
1304 cache: true
1305 run-install: |
1306 args:
1307 - --filter=@t3tools/marketing...
1308​
1309 - name: Deploy marketing site to Vercel
1310 shell: bash
1311 run: |
1312 set -euo pipefail
1313​
1314 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" ]]; then
1315 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID." >&2
1316 exit 1
1317 fi
1318​
1319 VERCEL_PROJECT_ID="$(
1320 curl --fail --silent --show-error \
1321 --header "Authorization: Bearer $VERCEL_TOKEN" \
1322 "https://api.vercel.com/v9/projects/t3code-marketing?teamId=$VERCEL_ORG_ID" \
1323 | jq --exit-status --raw-output '.id'
1324 )"
1325 export VERCEL_PROJECT_ID
1326​
1327 vp dlx vercel@53.1.1 deploy \
1328 --archive=tgz \
1329 --prod \
1330 --yes \
1331 --token "$VERCEL_TOKEN" \
1332 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1333​
1334 finalize:
1335 name: Finalize release
1336 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
1337 needs: [preflight, release]
1338 runs-on: blacksmith-8vcpu-ubuntu-2404
1339 timeout-minutes: 10
1340 steps:
1341 - id: app_token
1342 name: Mint release app token
1343 uses: actions/create-github-app-token@v2
1344 with:
1345 app-id: ${{ secrets.RELEASE_APP_ID }}
1346 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
1347 owner: ${{ github.repository_owner }}
1348​
1349 - name: Checkout
1350 uses: actions/checkout@v6
1351 with:
1352 ref: main
1353 fetch-depth: 0
1354 token: ${{ steps.app_token.outputs.token }}
1355 persist-credentials: true
1356 sparse-checkout: |
1357 /*
1358 !/.repos/
1359 sparse-checkout-cone-mode: false
1360​
1361 - id: app_bot
1362 name: Resolve GitHub App bot identity
1363 env:
1364 GH_TOKEN: ${{ steps.app_token.outputs.token }}
1365 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
1366 run: |
1367 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
1368 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
1369 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
1370​
1371 - name: Setup Vite+
1372 uses: voidzero-dev/setup-vp@v1
1373 with:
1374 node-version-file: package.json
1375 cache: true
1376 run-install: |
1377 args:
1378 - --filter=@t3tools/scripts...
1379 - --filter=@t3tools/oxlint-plugin-t3code...
1380​
1381 - id: update_versions
1382 name: Update version strings
1383 env:
1384 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
1385 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
1386​
1387 - name: Format package.json files
1388 if: steps.update_versions.outputs.changed == 'true'
1389 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
1390​
1391 - name: Refresh lockfile
1392 if: steps.update_versions.outputs.changed == 'true'
1393 run: vp install --lockfile-only --ignore-scripts
1394​
1395 - name: Commit and push version bump
1396 if: steps.update_versions.outputs.changed == 'true'
1397 shell: bash
1398 env:
1399 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1400 run: |
1401 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
1402 echo "No version changes to commit."
1403 exit 0
1404 fi
1405​
1406 git config user.name "${{ steps.app_bot.outputs.name }}"
1407 git config user.email "${{ steps.app_bot.outputs.email }}"
1408​
1409 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
1410 git commit -m "chore(release): prepare $RELEASE_TAG"
1411 git push origin HEAD:main
1412​
1413 announce_discord:
1414 name: Announce release on Discord
1415 if: |
1416 always() && !cancelled() &&
1417 needs.preflight.result == 'success' &&
1418 needs.preflight.outputs.release_channel != 'preview' &&
1419 needs.relay_public_config.result == 'success' &&
1420 needs.release.result == 'success' &&
1421 needs.deploy_web.result == 'success' &&
1422 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
1423 needs: [preflight, relay_public_config, release, deploy_web, finalize]
1424 runs-on: blacksmith-8vcpu-ubuntu-2404
1425 timeout-minutes: 10
1426 steps:
1427 - name: Checkout
1428 uses: actions/checkout@v6
1429 with:
1430 ref: ${{ needs.preflight.outputs.ref }}
1431 sparse-checkout: |
1432 /*
1433 !/.repos/
1434 sparse-checkout-cone-mode: false
1435​
1436 - name: Setup Vite+
1437 uses: voidzero-dev/setup-vp@v1
1438 with:
1439 node-version-file: package.json
1440 cache: true
1441 run-install: |
1442 args:
1443 - --filter=@t3tools/scripts...
1444​
1445 - name: Announce prerelease on Discord
1446 if: needs.preflight.outputs.is_prerelease == 'true'
1447 continue-on-error: true
1448 env:
1449 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
1450 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1451 run: |
1452 node scripts/notify-discord-release.ts prerelease \
1453 --role-id "$DISCORD_MENTION_ROLE_ID" \
1454 --release-name "${{ needs.preflight.outputs.release_name }}" \
1455 --release-version "${{ needs.preflight.outputs.version }}" \
1456 --tag "${{ needs.preflight.outputs.tag }}" \
1457 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"
1458​
1459 - name: Announce latest release on Discord
1460 if: needs.preflight.outputs.make_latest == 'true'
1461 continue-on-error: true
1462 env:
1463 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
1464 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1465 run: |
1466 node scripts/notify-discord-release.ts latest \
1467 --role-id "$DISCORD_MENTION_ROLE_ID" \
1468 --release-name "${{ needs.preflight.outputs.release_name }}" \
1469 --release-version "${{ needs.preflight.outputs.version }}" \
1470 --tag "${{ needs.preflight.outputs.tag }}" \
1471 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"