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

release.yml

828 lines30.6 KB

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: Install ImageMagick
256 if: matrix.platform == 'linux'
257 shell: bash
258 run: |
259 if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
260 sudo apt-get update
261 sudo apt-get install -y imagemagick
262 fi
263​
264 if command -v magick >/dev/null 2>&1; then
265 magick -version
266 else
267 convert -version
268 fi
269​
270 - name: Prepare Azure Trusted Signing
271 if: matrix.platform == 'win'
272 shell: pwsh
273 env:
274 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
275 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
276 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
277 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
278 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
279 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
280 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
281 run: |
282 $ErrorActionPreference = "Stop"
283​
284 $requiredSecrets = @(
285 $env:AZURE_TENANT_ID,
286 $env:AZURE_CLIENT_ID,
287 $env:AZURE_CLIENT_SECRET,
288 $env:AZURE_TRUSTED_SIGNING_ENDPOINT,
289 $env:AZURE_TRUSTED_SIGNING_ACCOUNT_NAME,
290 $env:AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME,
291 $env:AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
292 )
293 if ($requiredSecrets | Where-Object { [string]::IsNullOrWhiteSpace($_) }) {
294 Write-Host "Azure Trusted Signing disabled; skipping TrustedSigning module preparation."
295 exit 0
296 }
297​
298 try {
299 Install-PackageProvider `
300 -Name NuGet `
301 -MinimumVersion 2.8.5.201 `
302 -Force `
303 -Scope CurrentUser `
304 -ErrorAction Stop
305 } catch {
306 Write-Warning "Could not bootstrap NuGet package provider. Continuing because the runner may already have a usable provider. $($_.Exception.Message)"
307 }
308​
309 Install-Module `
310 -Name TrustedSigning `
311 -MinimumVersion 0.5.0 `
312 -Force `
313 -AllowClobber `
314 -Repository PSGallery `
315 -Scope CurrentUser `
316 -ErrorAction Stop
317​
318 Import-Module TrustedSigning -MinimumVersion 0.5.0 -Force
319 Get-Command Invoke-TrustedSigning -ErrorAction Stop
320​
321 $moduleRoots = @(
322 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "PowerShell", "Modules"),
323 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "WindowsPowerShell", "Modules"),
324 [System.IO.Path]::Combine($env:ProgramFiles, "PowerShell", "Modules"),
325 [System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules")
326 )
327 $modulePathEntries = @($moduleRoots + ($env:PSModulePath -split ";")) |
328 Where-Object { $_ -and (Test-Path $_) } |
329 Select-Object -Unique
330 "PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
331​
332 - name: Build desktop artifact
333 shell: bash
334 env:
335 CSC_LINK: ${{ secrets.CSC_LINK }}
336 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
337 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
338 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
339 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
340 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
341 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
342 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
343 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
344 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
345 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
346 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
347 run: |
348 args=(
349 --platform "${{ matrix.platform }}"
350 --target "${{ matrix.target }}"
351 --arch "${{ matrix.arch }}"
352 --build-version "${{ needs.preflight.outputs.version }}"
353 --verbose
354 )
355​
356 has_all() {
357 for value in "$@"; do
358 if [[ -z "$value" ]]; then
359 return 1
360 fi
361 done
362 return 0
363 }
364​
365 if [[ "${{ matrix.platform }}" == "mac" ]]; then
366 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
367 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
368 printf '%s' "$APPLE_API_KEY" > "$key_path"
369 export APPLE_API_KEY="$key_path"
370 echo "macOS signing enabled."
371 args+=(--signed)
372 else
373 echo "macOS signing disabled (missing one or more Apple signing secrets)."
374 fi
375 elif [[ "${{ matrix.platform }}" == "win" ]]; then
376 if has_all \
377 "$AZURE_TENANT_ID" \
378 "$AZURE_CLIENT_ID" \
379 "$AZURE_CLIENT_SECRET" \
380 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
381 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
382 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
383 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
384 echo "Windows signing enabled (Azure Trusted Signing)."
385 args+=(--signed)
386 else
387 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
388 fi
389 else
390 echo "Signing disabled for ${{ matrix.platform }}."
391 fi
392​
393 bun run dist:desktop:artifact -- "${args[@]}"
394​
395 - name: Collect release assets
396 shell: bash
397 run: |
398 set -euo pipefail
399 mkdir -p release-publish
400​
401 shopt -s nullglob
402 for pattern in \
403 "release/*.dmg" \
404 "release/*.zip" \
405 "release/*.AppImage" \
406 "release/*.exe" \
407 "release/*.blockmap" \
408 "release/*.yml"; do
409 for file in $pattern; do
410 cp "$file" release-publish/
411 done
412 done
413​
414 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
415 shopt -s nullglob
416 for manifest in release-publish/*-mac.yml; do
417 mv "$manifest" "${manifest%.yml}-${{ matrix.arch }}.yml"
418 done
419 fi
420​
421 # Enable if Windows arm64 builds are enabled.
422 # Windows updater metadata is channel-specific (for example
423 # "latest.yml" or "nightly.yml"). Suffix each per-arch copy so the
424 # release job can merge matching arm64/x64 manifests back into one
425 # canonical manifest per channel.
426 # if [[ "${{ matrix.platform }}" == "win" ]]; then
427 # shopt -s nullglob
428 # for manifest in release-publish/*.yml; do
429 # mv "$manifest" "${manifest%.yml}-win-${{ matrix.arch }}.yml"
430 # done
431 # fi
432​
433 - name: Upload build artifacts
434 uses: actions/upload-artifact@v7
435 with:
436 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
437 path: release-publish/*
438 if-no-files-found: error
439​
440 publish_cli:
441 name: Publish CLI to npm
442 needs: [preflight, build]
443 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' }}
444 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
445 timeout-minutes: 10
446 permissions:
447 contents: read
448 id-token: write
449 steps:
450 - name: Checkout
451 uses: actions/checkout@v6
452 with:
453 ref: ${{ needs.preflight.outputs.ref }}
454​
455 - name: Setup Bun
456 uses: oven-sh/setup-bun@v2
457 with:
458 bun-version-file: package.json
459​
460 - name: Setup Node
461 uses: actions/setup-node@v6
462 with:
463 node-version-file: package.json
464 registry-url: https://registry.npmjs.org
465​
466 - name: Install dependencies
467 run: bun install --frozen-lockfile --filter=t3 --filter=@t3tools/web --filter=@t3tools/scripts
468​
469 - name: Align package versions to release version
470 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
471​
472 - name: Build web package
473 run: bun --filter=@t3tools/web run build
474​
475 - name: Build CLI package
476 run: bun --filter=t3 run build
477​
478 - name: Publish CLI package
479 run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
480​
481 release:
482 name: Publish GitHub Release
483 needs: [preflight, build, publish_cli]
484 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' && needs.publish_cli.result == 'success' }}
485 runs-on: blacksmith-8vcpu-ubuntu-2404
486 timeout-minutes: 10
487 steps:
488 - id: app_token
489 name: Mint release app token
490 uses: actions/create-github-app-token@v2
491 with:
492 app-id: ${{ secrets.RELEASE_APP_ID }}
493 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
494 owner: ${{ github.repository_owner }}
495​
496 - name: Checkout
497 uses: actions/checkout@v6
498 with:
499 ref: ${{ needs.preflight.outputs.ref }}
500​
501 - name: Setup Bun
502 uses: oven-sh/setup-bun@v2
503 with:
504 bun-version-file: package.json
505​
506 - name: Setup Node
507 uses: actions/setup-node@v6
508 with:
509 node-version-file: package.json
510​
511 - name: Install dependencies
512 run: bun install --frozen-lockfile --filter=@t3tools/scripts
513​
514 - name: Download all desktop artifacts
515 uses: actions/download-artifact@v8
516 with:
517 pattern: desktop-*
518 merge-multiple: true
519 path: release-assets
520​
521 - name: Merge macOS updater manifests
522 run: |
523 shopt -s nullglob
524 for x64_manifest in release-assets/*-mac-x64.yml; do
525 arm64_manifest="${x64_manifest%-x64.yml}.yml"
526 if [[ -f "$arm64_manifest" ]]; then
527 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
528 rm -f "$x64_manifest"
529 fi
530 done
531​
532 # - name: Merge Windows updater manifests
533 # run: |
534 # shopt -s nullglob
535 # found_windows_manifest=false
536 # for x64_manifest in release-assets/*-win-x64.yml; do
537 # if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
538 # continue
539 # fi
540​
541 # arm64_manifest="${x64_manifest/-x64.yml/-arm64.yml}"
542 # output_manifest="${x64_manifest/-win-x64.yml/.yml}"
543 # if [[ ! -f "$arm64_manifest" ]]; then
544 # echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
545 # exit 1
546 # fi
547​
548 # found_windows_manifest=true
549 # node scripts/merge-update-manifests.ts --platform win \
550 # "$arm64_manifest" \
551 # "$x64_manifest" \
552 # "$output_manifest"
553 # rm -f "$arm64_manifest" "$x64_manifest"
554 # done
555​
556 # if [[ "$found_windows_manifest" != true ]]; then
557 # echo "No Windows updater manifests found to merge." >&2
558 # exit 1
559 # fi
560​
561 - name: Publish release
562 if: needs.preflight.outputs.previous_tag != ''
563 uses: softprops/action-gh-release@v2
564 with:
565 tag_name: ${{ needs.preflight.outputs.tag }}
566 target_commitish: ${{ needs.preflight.outputs.ref }}
567 name: ${{ needs.preflight.outputs.release_name }}
568 generate_release_notes: true
569 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
570 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
571 make_latest: ${{ needs.preflight.outputs.make_latest }}
572 files: |
573 release-assets/*.dmg
574 release-assets/*.zip
575 release-assets/*.AppImage
576 release-assets/*.exe
577 release-assets/*.blockmap
578 release-assets/*.yml
579 fail_on_unmatched_files: true
580 token: ${{ steps.app_token.outputs.token }}
581​
582 - name: Publish first release
583 if: needs.preflight.outputs.previous_tag == ''
584 uses: softprops/action-gh-release@v2
585 with:
586 tag_name: ${{ needs.preflight.outputs.tag }}
587 target_commitish: ${{ needs.preflight.outputs.ref }}
588 name: ${{ needs.preflight.outputs.release_name }}
589 generate_release_notes: true
590 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
591 make_latest: ${{ needs.preflight.outputs.make_latest }}
592 files: |
593 release-assets/*.dmg
594 release-assets/*.zip
595 release-assets/*.AppImage
596 release-assets/*.exe
597 release-assets/*.blockmap
598 release-assets/*.yml
599 fail_on_unmatched_files: true
600 token: ${{ steps.app_token.outputs.token }}
601​
602 deploy_web:
603 name: Deploy hosted web app
604 needs: [preflight, release]
605 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
606 runs-on: blacksmith-8vcpu-ubuntu-2404
607 timeout-minutes: 10
608 env:
609 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
610 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
611 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
612 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
613 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
614 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
615 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
616 steps:
617 - name: Checkout
618 uses: actions/checkout@v6
619 with:
620 ref: ${{ needs.preflight.outputs.ref }}
621​
622 - name: Setup Bun
623 uses: oven-sh/setup-bun@v2
624 with:
625 bun-version-file: package.json
626​
627 - name: Setup Node
628 uses: actions/setup-node@v6
629 with:
630 node-version-file: package.json
631​
632 - name: Install release tooling dependencies
633 run: bun install --frozen-lockfile --filter=@t3tools/scripts --filter=@t3tools/web
634​
635 - name: Align package versions to release version
636 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
637​
638 - name: Refresh release lockfile
639 run: bun install --lockfile-only --ignore-scripts
640​
641 - name: Deploy and alias channel
642 shell: bash
643 run: |
644 set -euo pipefail
645​
646 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
647 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
648 exit 1
649 fi
650​
651 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
652 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
653 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
654 router_domain="${router_url#http://}"
655 router_domain="${router_domain#https://}"
656 router_domain="${router_domain%%/*}"
657​
658 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
659 channel_domain="$latest_domain"
660 channel_name="latest"
661 else
662 channel_domain="$nightly_domain"
663 channel_name="nightly"
664 fi
665​
666 vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
667 vercel_scope_args=(--scope "$vercel_scope")
668​
669 echo "Deploying hosted web app for $channel_name channel."
670 deployment_url="$(
671 bunx vercel@53.1.1 deploy \
672 --prod \
673 --skip-domain \
674 --yes \
675 --token "$VERCEL_TOKEN" \
676 "${vercel_scope_args[@]}" \
677 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
678 --build-env "VITE_HOSTED_APP_URL=$router_url" \
679 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
680 )"
681​
682 echo "Aliasing $deployment_url to $channel_domain."
683 bunx vercel@53.1.1 alias set "$deployment_url" "$channel_domain" \
684 --token "$VERCEL_TOKEN" \
685 "${vercel_scope_args[@]}"
686​
687 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
688 echo "Aliasing $deployment_url to router domain $router_domain."
689 bunx vercel@53.1.1 alias set "$deployment_url" "$router_domain" \
690 --token "$VERCEL_TOKEN" \
691 "${vercel_scope_args[@]}"
692 fi
693​
694 finalize:
695 name: Finalize release
696 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
697 needs: [preflight, release]
698 runs-on: blacksmith-8vcpu-ubuntu-2404
699 timeout-minutes: 10
700 steps:
701 - id: app_token
702 name: Mint release app token
703 uses: actions/create-github-app-token@v2
704 with:
705 app-id: ${{ secrets.RELEASE_APP_ID }}
706 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
707 owner: ${{ github.repository_owner }}
708​
709 - name: Checkout
710 uses: actions/checkout@v6
711 with:
712 ref: main
713 fetch-depth: 0
714 token: ${{ steps.app_token.outputs.token }}
715 persist-credentials: true
716​
717 - id: app_bot
718 name: Resolve GitHub App bot identity
719 env:
720 GH_TOKEN: ${{ steps.app_token.outputs.token }}
721 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
722 run: |
723 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
724 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
725 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
726​
727 - name: Setup Bun
728 uses: oven-sh/setup-bun@v2
729 with:
730 bun-version-file: package.json
731​
732 - name: Setup Node
733 uses: actions/setup-node@v6
734 with:
735 node-version-file: package.json
736​
737 - name: Install dependencies
738 run: bun install --frozen-lockfile --filter=@t3tools/scripts
739​
740 - id: update_versions
741 name: Update version strings
742 env:
743 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
744 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
745​
746 - name: Format package.json files
747 if: steps.update_versions.outputs.changed == 'true'
748 run: bunx oxfmt@0.40.0 apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
749​
750 - name: Refresh lockfile
751 if: steps.update_versions.outputs.changed == 'true'
752 run: bun install --lockfile-only --ignore-scripts
753​
754 - name: Commit and push version bump
755 if: steps.update_versions.outputs.changed == 'true'
756 shell: bash
757 env:
758 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
759 run: |
760 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock; then
761 echo "No version changes to commit."
762 exit 0
763 fi
764​
765 git config user.name "${{ steps.app_bot.outputs.name }}"
766 git config user.email "${{ steps.app_bot.outputs.email }}"
767​
768 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
769 git commit -m "chore(release): prepare $RELEASE_TAG"
770 git push origin HEAD:main
771​
772 announce_discord:
773 name: Announce release on Discord
774 if: |
775 always() && !cancelled() &&
776 needs.preflight.result == 'success' &&
777 needs.release.result == 'success' &&
778 needs.deploy_web.result == 'success' &&
779 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
780 needs: [preflight, release, deploy_web, finalize]
781 runs-on: blacksmith-8vcpu-ubuntu-2404
782 timeout-minutes: 10
783 steps:
784 - name: Checkout
785 uses: actions/checkout@v6
786 with:
787 ref: ${{ needs.preflight.outputs.ref }}
788​
789 - name: Setup Bun
790 uses: oven-sh/setup-bun@v2
791 with:
792 bun-version-file: package.json
793​
794 - name: Setup Node
795 uses: actions/setup-node@v6
796 with:
797 node-version-file: package.json
798​
799 - name: Install dependencies
800 run: bun install --frozen-lockfile --filter=@t3tools/scripts
801​
802 - name: Announce prerelease on Discord
803 if: needs.preflight.outputs.is_prerelease == 'true'
804 continue-on-error: true
805 env:
806 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
807 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
808 run: |
809 node scripts/notify-discord-release.ts prerelease \
810 --role-id "$DISCORD_MENTION_ROLE_ID" \
811 --release-name "${{ needs.preflight.outputs.release_name }}" \
812 --release-version "${{ needs.preflight.outputs.version }}" \
813 --tag "${{ needs.preflight.outputs.tag }}" \
814 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"
815​
816 - name: Announce latest release on Discord
817 if: needs.preflight.outputs.make_latest == 'true'
818 continue-on-error: true
819 env:
820 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
821 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
822 run: |
823 node scripts/notify-discord-release.ts latest \
824 --role-id "$DISCORD_MENTION_ROLE_ID" \
825 --release-name "${{ needs.preflight.outputs.release_name }}" \
826 --release-version "${{ needs.preflight.outputs.version }}" \
827 --tag "${{ needs.preflight.outputs.tag }}" \
828 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"