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 Bun
89 uses: oven-sh/setup-bun@v2
90 with:
91 bun-version-file: package.json
92
93 - name: Setup Node
94 uses: actions/setup-node@v6
95 with:
96 node-version-file: package.json
97
98 - name: Install dependencies
99 run: bun install --frozen-lockfile
100
101 - id: release_meta
102 name: Resolve release version
103 shell: bash
104 env:
105 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
106 DISPATCH_VERSION: ${{ github.event.inputs.version }}
107 NIGHTLY_DATE: ${{ github.run_started_at }}
108 NIGHTLY_SHA: ${{ github.sha }}
109 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
110 run: |
111 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ) ]]; then
112 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
113
114 node scripts/resolve-nightly-release.ts \
115 --date "$nightly_date" \
116 --run-number "$NIGHTLY_RUN_NUMBER" \
117 --sha "$NIGHTLY_SHA" \
118 --github-output
119
120 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
121 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
122 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
123 echo "make_latest=false" >> "$GITHUB_OUTPUT"
124 else
125 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
126 raw="${DISPATCH_VERSION}"
127 if [[ -z "$raw" ]]; then
128 echo "workflow_dispatch stable releases require the version input." >&2
129 exit 1
130 fi
131 else
132 raw="${GITHUB_REF_NAME}"
133 fi
134
135 version="${raw#v}"
136 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
137 echo "Invalid release version: $raw" >&2
138 exit 1
139 fi
140
141 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
142 echo "version=$version" >> "$GITHUB_OUTPUT"
143 echo "tag=v$version" >> "$GITHUB_OUTPUT"
144 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
145 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
146 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
147 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
148 echo "make_latest=true" >> "$GITHUB_OUTPUT"
149 else
150 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
151 echo "make_latest=false" >> "$GITHUB_OUTPUT"
152 fi
153 fi
154
155 - name: Lint
156 run: bun run lint
157
158 - name: Typecheck
159 run: bun run typecheck
160
161 - name: Test
162 run: bun run test
163
164 - id: previous_tag
165 name: Resolve previous release tag
166 run: |
167 node scripts/resolve-previous-release-tag.ts \
168 --channel "${{ steps.release_meta.outputs.release_channel }}" \
169 --current-tag "${{ steps.release_meta.outputs.tag }}" \
170 --github-output
171
172 build:
173 name: Build ${{ matrix.label }}
174 needs: preflight
175 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
176 runs-on: ${{ matrix.runner }}
177 timeout-minutes: 30
178 strategy:
179 fail-fast: false
180 matrix:
181 include:
182 - label: macOS arm64
183 runner: blacksmith-12vcpu-macos-26
184 platform: mac
185 target: dmg
186 arch: arm64
187 - label: macOS x64
188 runner: blacksmith-12vcpu-macos-26
189 platform: mac
190 target: dmg
191 arch: x64
192 - label: Linux x64
193 runner: blacksmith-32vcpu-ubuntu-2404
194 platform: linux
195 target: AppImage
196 arch: x64
197 - label: Windows x64
198 runner: blacksmith-32vcpu-windows-2025
199 platform: win
200 target: nsis
201 arch: x64
202 # - label: Windows arm64
203 # runner: windows-11-arm
204 # platform: win
205 # target: nsis
206 # arch: arm64
207 steps:
208 - name: Checkout
209 uses: actions/checkout@v6
210 with:
211 ref: ${{ needs.preflight.outputs.ref }}
212 fetch-depth: 0
213
214 - name: Setup Bun
215 uses: oven-sh/setup-bun@v2
216 with:
217 bun-version-file: package.json
218
219 - name: Setup Node
220 uses: actions/setup-node@v6
221 with:
222 node-version-file: package.json
223
224 - name: Install dependencies
225 run: bun install --frozen-lockfile
226
227 - name: Align package versions to release version
228 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
229
230 - name: Install Spectre-mitigated MSVC libs
231 if: matrix.platform == 'win'
232 shell: pwsh
233 run: |
234 $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
235 $installPath = & $vswhere -products * -latest -property installationPath
236 $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
237 $proc = Start-Process -FilePath $setupExe `
238 -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
239 "Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre", "--quiet", "--norestart" `
240 -Wait -PassThru -NoNewWindow
241 if ($null -eq $proc -or $proc.ExitCode -ne 0) {
242 $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
243 Write-Error "Visual Studio Installer failed with exit code $code"
244 exit $code
245 }
246
247 - name: Prepare Azure Trusted Signing
248 if: matrix.platform == 'win'
249 shell: pwsh
250 env:
251 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
252 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
253 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
254 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
255 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
256 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
257 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
258 run: |
259 $ErrorActionPreference = "Stop"
260
261 $requiredSecrets = @(
262 $env:AZURE_TENANT_ID,
263 $env:AZURE_CLIENT_ID,
264 $env:AZURE_CLIENT_SECRET,
265 $env:AZURE_TRUSTED_SIGNING_ENDPOINT,
266 $env:AZURE_TRUSTED_SIGNING_ACCOUNT_NAME,
267 $env:AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME,
268 $env:AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
269 )
270 if ($requiredSecrets | Where-Object { [string]::IsNullOrWhiteSpace($_) }) {
271 Write-Host "Azure Trusted Signing disabled; skipping TrustedSigning module preparation."
272 exit 0
273 }
274
275 try {
276 Install-PackageProvider `
277 -Name NuGet `
278 -MinimumVersion 2.8.5.201 `
279 -Force `
280 -Scope CurrentUser `
281 -ErrorAction Stop
282 } catch {
283 Write-Warning "Could not bootstrap NuGet package provider. Continuing because the runner may already have a usable provider. $($_.Exception.Message)"
284 }
285
286 Install-Module `
287 -Name TrustedSigning `
288 -MinimumVersion 0.5.0 `
289 -Force `
290 -AllowClobber `
291 -Repository PSGallery `
292 -Scope CurrentUser `
293 -ErrorAction Stop
294
295 Import-Module TrustedSigning -MinimumVersion 0.5.0 -Force
296 Get-Command Invoke-TrustedSigning -ErrorAction Stop
297
298 $moduleRoots = @(
299 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "PowerShell", "Modules"),
300 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "WindowsPowerShell", "Modules"),
301 [System.IO.Path]::Combine($env:ProgramFiles, "PowerShell", "Modules"),
302 [System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules")
303 )
304 $modulePathEntries = @($moduleRoots + ($env:PSModulePath -split ";")) |
305 Where-Object { $_ -and (Test-Path $_) } |
306 Select-Object -Unique
307 "PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
308
309 - name: Build desktop artifact
310 shell: bash
311 env:
312 CSC_LINK: ${{ secrets.CSC_LINK }}
313 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
314 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
315 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
316 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
317 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
318 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
319 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
320 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
321 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
322 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
323 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
324 run: |
325 args=(
326 --platform "${{ matrix.platform }}"
327 --target "${{ matrix.target }}"
328 --arch "${{ matrix.arch }}"
329 --build-version "${{ needs.preflight.outputs.version }}"
330 --verbose
331 )
332
333 has_all() {
334 for value in "$@"; do
335 if [[ -z "$value" ]]; then
336 return 1
337 fi
338 done
339 return 0
340 }
341
342 if [[ "${{ matrix.platform }}" == "mac" ]]; then
343 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
344 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
345 printf '%s' "$APPLE_API_KEY" > "$key_path"
346 export APPLE_API_KEY="$key_path"
347 echo "macOS signing enabled."
348 args+=(--signed)
349 else
350 echo "macOS signing disabled (missing one or more Apple signing secrets)."
351 fi
352 elif [[ "${{ matrix.platform }}" == "win" ]]; then
353 if has_all \
354 "$AZURE_TENANT_ID" \
355 "$AZURE_CLIENT_ID" \
356 "$AZURE_CLIENT_SECRET" \
357 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
358 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
359 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
360 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
361 echo "Windows signing enabled (Azure Trusted Signing)."
362 args+=(--signed)
363 else
364 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
365 fi
366 else
367 echo "Signing disabled for ${{ matrix.platform }}."
368 fi
369
370 bun run dist:desktop:artifact -- "${args[@]}"
371
372 - name: Collect release assets
373 shell: bash
374 run: |
375 set -euo pipefail
376 mkdir -p release-publish
377
378 shopt -s nullglob
379 for pattern in \
380 "release/*.dmg" \
381 "release/*.zip" \
382 "release/*.AppImage" \
383 "release/*.exe" \
384 "release/*.blockmap" \
385 "release/*.yml"; do
386 for file in $pattern; do
387 cp "$file" release-publish/
388 done
389 done
390
391 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
392 shopt -s nullglob
393 for manifest in release-publish/*-mac.yml; do
394 mv "$manifest" "${manifest%.yml}-${{ matrix.arch }}.yml"
395 done
396 fi
397
398 # Enable if Windows arm64 builds are enabled.
399 # Windows updater metadata is channel-specific (for example
400 # "latest.yml" or "nightly.yml"). Suffix each per-arch copy so the
401 # release job can merge matching arm64/x64 manifests back into one
402 # canonical manifest per channel.
403 # if [[ "${{ matrix.platform }}" == "win" ]]; then
404 # shopt -s nullglob
405 # for manifest in release-publish/*.yml; do
406 # mv "$manifest" "${manifest%.yml}-win-${{ matrix.arch }}.yml"
407 # done
408 # fi
409
410 - name: Upload build artifacts
411 uses: actions/upload-artifact@v7
412 with:
413 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
414 path: release-publish/*
415 if-no-files-found: error
416
417 publish_cli:
418 name: Publish CLI to npm
419 needs: [preflight, build]
420 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' }}
421 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
422 timeout-minutes: 10
423 permissions:
424 contents: read
425 id-token: write
426 steps:
427 - name: Checkout
428 uses: actions/checkout@v6
429 with:
430 ref: ${{ needs.preflight.outputs.ref }}
431
432 - name: Setup Bun
433 uses: oven-sh/setup-bun@v2
434 with:
435 bun-version-file: package.json
436
437 - name: Setup Node
438 uses: actions/setup-node@v6
439 with:
440 node-version-file: package.json
441 registry-url: https://registry.npmjs.org
442
443 - name: Install dependencies
444 run: bun install --frozen-lockfile --filter=t3 --filter=@t3tools/web --filter=@t3tools/scripts
445
446 - name: Align package versions to release version
447 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
448
449 - name: Build web package
450 run: bun --filter=@t3tools/web run build
451
452 - name: Build CLI package
453 run: bun --filter=t3 run build
454
455 - name: Publish CLI package
456 run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
457
458 release:
459 name: Publish GitHub Release
460 needs: [preflight, build, publish_cli]
461 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' && needs.publish_cli.result == 'success' }}
462 runs-on: blacksmith-8vcpu-ubuntu-2404
463 timeout-minutes: 10
464 steps:
465 - id: app_token
466 name: Mint release app token
467 uses: actions/create-github-app-token@v2
468 with:
469 app-id: ${{ secrets.RELEASE_APP_ID }}
470 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
471 owner: ${{ github.repository_owner }}
472
473 - name: Checkout
474 uses: actions/checkout@v6
475 with:
476 ref: ${{ needs.preflight.outputs.ref }}
477
478 - name: Setup Bun
479 uses: oven-sh/setup-bun@v2
480 with:
481 bun-version-file: package.json
482
483 - name: Setup Node
484 uses: actions/setup-node@v6
485 with:
486 node-version-file: package.json
487
488 - name: Install dependencies
489 run: bun install --frozen-lockfile --filter=@t3tools/scripts
490
491 - name: Download all desktop artifacts
492 uses: actions/download-artifact@v8
493 with:
494 pattern: desktop-*
495 merge-multiple: true
496 path: release-assets
497
498 - name: Merge macOS updater manifests
499 run: |
500 shopt -s nullglob
501 for x64_manifest in release-assets/*-mac-x64.yml; do
502 arm64_manifest="${x64_manifest%-x64.yml}.yml"
503 if [[ -f "$arm64_manifest" ]]; then
504 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
505 rm -f "$x64_manifest"
506 fi
507 done
508
509 # - name: Merge Windows updater manifests
510 # run: |
511 # shopt -s nullglob
512 # found_windows_manifest=false
513 # for x64_manifest in release-assets/*-win-x64.yml; do
514 # if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
515 # continue
516 # fi
517
518 # arm64_manifest="${x64_manifest/-x64.yml/-arm64.yml}"
519 # output_manifest="${x64_manifest/-win-x64.yml/.yml}"
520 # if [[ ! -f "$arm64_manifest" ]]; then
521 # echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
522 # exit 1
523 # fi
524
525 # found_windows_manifest=true
526 # node scripts/merge-update-manifests.ts --platform win \
527 # "$arm64_manifest" \
528 # "$x64_manifest" \
529 # "$output_manifest"
530 # rm -f "$arm64_manifest" "$x64_manifest"
531 # done
532
533 # if [[ "$found_windows_manifest" != true ]]; then
534 # echo "No Windows updater manifests found to merge." >&2
535 # exit 1
536 # fi
537
538 - name: Publish release
539 if: needs.preflight.outputs.previous_tag != ''
540 uses: softprops/action-gh-release@v2
541 with:
542 tag_name: ${{ needs.preflight.outputs.tag }}
543 target_commitish: ${{ needs.preflight.outputs.ref }}
544 name: ${{ needs.preflight.outputs.release_name }}
545 generate_release_notes: true
546 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
547 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
548 make_latest: ${{ needs.preflight.outputs.make_latest }}
549 files: |
550 release-assets/*.dmg
551 release-assets/*.zip
552 release-assets/*.AppImage
553 release-assets/*.exe
554 release-assets/*.blockmap
555 release-assets/*.yml
556 fail_on_unmatched_files: true
557 token: ${{ steps.app_token.outputs.token }}
558
559 - name: Publish first release
560 if: needs.preflight.outputs.previous_tag == ''
561 uses: softprops/action-gh-release@v2
562 with:
563 tag_name: ${{ needs.preflight.outputs.tag }}
564 target_commitish: ${{ needs.preflight.outputs.ref }}
565 name: ${{ needs.preflight.outputs.release_name }}
566 generate_release_notes: true
567 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
568 make_latest: ${{ needs.preflight.outputs.make_latest }}
569 files: |
570 release-assets/*.dmg
571 release-assets/*.zip
572 release-assets/*.AppImage
573 release-assets/*.exe
574 release-assets/*.blockmap
575 release-assets/*.yml
576 fail_on_unmatched_files: true
577 token: ${{ steps.app_token.outputs.token }}
578
579 deploy_web:
580 name: Deploy hosted web app
581 needs: [preflight, release]
582 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
583 runs-on: blacksmith-8vcpu-ubuntu-2404
584 timeout-minutes: 10
585 env:
586 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
587 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
588 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
589 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
590 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
591 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
592 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
593 steps:
594 - name: Checkout
595 uses: actions/checkout@v6
596 with:
597 ref: ${{ needs.preflight.outputs.ref }}
598
599 - name: Setup Bun
600 uses: oven-sh/setup-bun@v2
601 with:
602 bun-version-file: package.json
603
604 - name: Setup Node
605 uses: actions/setup-node@v6
606 with:
607 node-version-file: package.json
608
609 - name: Install release tooling dependencies
610 run: bun install --frozen-lockfile --filter=@t3tools/scripts --filter=@t3tools/web
611
612 - name: Align package versions to release version
613 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
614
615 - name: Refresh release lockfile
616 run: bun install --lockfile-only --ignore-scripts
617
618 - name: Deploy and alias channel
619 shell: bash
620 run: |
621 set -euo pipefail
622
623 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
624 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
625 exit 1
626 fi
627
628 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
629 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
630 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
631 router_domain="${router_url#http://}"
632 router_domain="${router_domain#https://}"
633 router_domain="${router_domain%%/*}"
634
635 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
636 channel_domain="$latest_domain"
637 channel_name="latest"
638 else
639 channel_domain="$nightly_domain"
640 channel_name="nightly"
641 fi
642
643 vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
644 vercel_scope_args=(--scope "$vercel_scope")
645
646 echo "Deploying hosted web app for $channel_name channel."
647 deployment_url="$(
648 bunx vercel@53.1.1 deploy \
649 --prod \
650 --skip-domain \
651 --yes \
652 --token "$VERCEL_TOKEN" \
653 "${vercel_scope_args[@]}" \
654 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
655 --build-env "VITE_HOSTED_APP_URL=$router_url" \
656 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
657 )"
658
659 echo "Aliasing $deployment_url to $channel_domain."
660 bunx vercel@53.1.1 alias set "$deployment_url" "$channel_domain" \
661 --token "$VERCEL_TOKEN" \
662 "${vercel_scope_args[@]}"
663
664 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
665 echo "Aliasing $deployment_url to router domain $router_domain."
666 bunx vercel@53.1.1 alias set "$deployment_url" "$router_domain" \
667 --token "$VERCEL_TOKEN" \
668 "${vercel_scope_args[@]}"
669 fi
670
671 finalize:
672 name: Finalize release
673 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
674 needs: [preflight, release]
675 runs-on: blacksmith-8vcpu-ubuntu-2404
676 timeout-minutes: 10
677 steps:
678 - id: app_token
679 name: Mint release app token
680 uses: actions/create-github-app-token@v2
681 with:
682 app-id: ${{ secrets.RELEASE_APP_ID }}
683 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
684 owner: ${{ github.repository_owner }}
685
686 - name: Checkout
687 uses: actions/checkout@v6
688 with:
689 ref: main
690 fetch-depth: 0
691 token: ${{ steps.app_token.outputs.token }}
692 persist-credentials: true
693
694 - id: app_bot
695 name: Resolve GitHub App bot identity
696 env:
697 GH_TOKEN: ${{ steps.app_token.outputs.token }}
698 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
699 run: |
700 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
701 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
702 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
703
704 - name: Setup Bun
705 uses: oven-sh/setup-bun@v2
706 with:
707 bun-version-file: package.json
708
709 - name: Setup Node
710 uses: actions/setup-node@v6
711 with:
712 node-version-file: package.json
713
714 - name: Install dependencies
715 run: bun install --frozen-lockfile --filter=@t3tools/scripts
716
717 - id: update_versions
718 name: Update version strings
719 env:
720 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
721 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
722
723 - name: Format package.json files
724 if: steps.update_versions.outputs.changed == 'true'
725 run: bunx oxfmt@0.40.0 apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
726
727 - name: Refresh lockfile
728 if: steps.update_versions.outputs.changed == 'true'
729 run: bun install --lockfile-only --ignore-scripts
730
731 - name: Commit and push version bump
732 if: steps.update_versions.outputs.changed == 'true'
733 shell: bash
734 env:
735 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
736 run: |
737 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock; then
738 echo "No version changes to commit."
739 exit 0
740 fi
741
742 git config user.name "${{ steps.app_bot.outputs.name }}"
743 git config user.email "${{ steps.app_bot.outputs.email }}"
744
745 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
746 git commit -m "chore(release): prepare $RELEASE_TAG"
747 git push origin HEAD:main
748
749 announce_discord:
750 name: Announce release on Discord
751 if: |
752 always() && !cancelled() &&
753 needs.preflight.result == 'success' &&
754 needs.release.result == 'success' &&
755 needs.deploy_web.result == 'success' &&
756 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
757 needs: [preflight, release, deploy_web, finalize]
758 runs-on: blacksmith-8vcpu-ubuntu-2404
759 timeout-minutes: 10
760 steps:
761 - name: Checkout
762 uses: actions/checkout@v6
763 with:
764 ref: ${{ needs.preflight.outputs.ref }}
765
766 - name: Setup Bun
767 uses: oven-sh/setup-bun@v2
768 with:
769 bun-version-file: package.json
770
771 - name: Setup Node
772 uses: actions/setup-node@v6
773 with:
774 node-version-file: package.json
775
776 - name: Install dependencies
777 run: bun install --frozen-lockfile --filter=@t3tools/scripts
778
779 - name: Announce prerelease on Discord
780 if: needs.preflight.outputs.is_prerelease == 'true'
781 continue-on-error: true
782 env:
783 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
784 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
785 run: |
786 node scripts/notify-discord-release.ts prerelease \
787 --role-id "$DISCORD_MENTION_ROLE_ID" \
788 --release-name "${{ needs.preflight.outputs.release_name }}" \
789 --release-version "${{ needs.preflight.outputs.version }}" \
790 --tag "${{ needs.preflight.outputs.tag }}" \
791 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"
792
793 - name: Announce latest release on Discord
794 if: needs.preflight.outputs.make_latest == 'true'
795 continue-on-error: true
796 env:
797 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
798 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
799 run: |
800 node scripts/notify-discord-release.ts latest \
801 --role-id "$DISCORD_MENTION_ROLE_ID" \
802 --release-name "${{ needs.preflight.outputs.release_name }}" \
803 --release-version "${{ needs.preflight.outputs.version }}" \
804 --tag "${{ needs.preflight.outputs.tag }}" \
805 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"