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