Open History to see the last commit
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: preview
18 type: choice
19 options:
20 - preview
21 - stable
22 - nightly
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 # The Windows desktop jobs read this run's artifact list to wait for the
41 # Linux CLI archive they embed (see release-desktop.yml).
42 actions: read
43 contents: read
44 id-token: none
45
46jobs:
47 # Picks the commit every later job builds. Nightlies and tag pushes build the
48 # triggering commit. Manual stable releases build the commit of the latest
49 # published nightly, so stable only ever ships a build that nightly users
50 # have already run. Scheduled runs also decide here whether a nightly is due.
51 resolve_commit:
52 name: Resolve release commit
53 if: github.repository == 'pingdotgg/t3code'
54 runs-on: blacksmith-8vcpu-ubuntu-2404
55 timeout-minutes: 5
56 outputs:
57 ref: ${{ steps.resolve.outputs.ref }}
58 nightly_version: ${{ steps.resolve.outputs.nightly_version }}
59 has_changes: ${{ steps.resolve.outputs.has_changes }}
60 steps:
61 - name: Checkout
62 uses: actions/checkout@v6
63 with:
64 sparse-checkout: .github/scripts
65
66 - id: resolve
67 name: Resolve release commit
68 uses: actions/github-script@v8
69 env:
70 DISPATCH_CHANNEL: ${{ inputs.channel }}
71 with:
72 script: |
73 const {
74 assertCommitOnDefaultBranch,
75 assertReleaseSource,
76 shouldReleaseNightly,
77 resolveLatestNightlyCommit,
78 } = require('./.github/scripts/check-nightly-release.cjs');
79
80 const dispatchChannel = process.env.DISPATCH_CHANNEL || 'preview';
81 const releaseChannel = context.eventName === 'schedule'
82 ? 'nightly'
83 : context.eventName === 'workflow_dispatch'
84 ? dispatchChannel
85 : 'stable';
86
87 await assertReleaseSource({ github, context, releaseChannel });
88
89 if (context.eventName === 'schedule') {
90 core.setOutput('has_changes', await shouldReleaseNightly({ github, context, core }));
91 core.setOutput('ref', context.sha);
92 } else if (context.eventName === 'workflow_dispatch' && dispatchChannel === 'stable') {
93 const { tag, sha, version } = await resolveLatestNightlyCommit({ github, context, core });
94 await assertCommitOnDefaultBranch({ github, context, sha });
95 core.notice(`Stable release builds ${sha}, the commit shipped by ${tag}.`);
96 core.setOutput('ref', sha);
97 core.setOutput('nightly_version', version);
98 } else {
99 core.setOutput('ref', context.sha);
100 }
101
102 preflight:
103 name: Preflight
104 needs: [resolve_commit]
105 if: |
106 needs.resolve_commit.result == 'success' &&
107 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
108 runs-on: blacksmith-8vcpu-ubuntu-2404
109 timeout-minutes: 10
110 outputs:
111 release_channel: ${{ steps.release_meta.outputs.release_channel }}
112 version: ${{ steps.release_meta.outputs.version }}
113 tag: ${{ steps.release_meta.outputs.tag }}
114 release_name: ${{ steps.release_meta.outputs.name }}
115 short_sha: ${{ steps.release_meta.outputs.short_sha }}
116 previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
117 cli_dist_tag: ${{ steps.release_meta.outputs.cli_dist_tag }}
118 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
119 make_latest: ${{ steps.release_meta.outputs.make_latest }}
120 ref: ${{ needs.resolve_commit.outputs.ref }}
121 steps:
122 - name: Checkout
123 uses: actions/checkout@v6
124 with:
125 ref: ${{ needs.resolve_commit.outputs.ref }}
126 fetch-depth: 0
127 sparse-checkout: |
128 /*
129 !/.repos/
130 sparse-checkout-cone-mode: false
131
132 - name: Setup dependencies
133 uses: ./.github/actions/setup-ci-deps
134 with:
135 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
136 env:
137 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
138
139 - id: release_meta
140 name: Resolve release version
141 shell: bash
142 env:
143 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
144 DISPATCH_VERSION: ${{ github.event.inputs.version }}
145 NIGHTLY_VERSION: ${{ needs.resolve_commit.outputs.nightly_version }}
146 NIGHTLY_DATE: ${{ github.run_started_at }}
147 NIGHTLY_SHA: ${{ needs.resolve_commit.outputs.ref }}
148 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
149 run: |
150 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-preview}" == "nightly" ) ]]; then
151 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
152
153 node scripts/resolve-nightly-release.ts \
154 --date "$nightly_date" \
155 --run-number "$NIGHTLY_RUN_NUMBER" \
156 --sha "$NIGHTLY_SHA" \
157 --github-output
158
159 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
160 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
161 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
162 echo "make_latest=false" >> "$GITHUB_OUTPUT"
163 elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-preview}" == "preview" ]]; then
164 # Manual-only test train: exercises the whole release flow for a
165 # commit end users must never receive. Never scheduled.
166 # Same versioning as nightly under its own prerelease identifier.
167 # A preview release is reachable only by asking for it: npm gets it
168 # under the `preview` dist-tag, which nothing resolves by default,
169 # its desktop builds carry no update feed, and no updater manifest
170 # is attached to the release, so neither stable nor nightly
171 # installs can ever be offered one.
172 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
173
174 node scripts/resolve-nightly-release.ts \
175 --channel preview \
176 --date "$nightly_date" \
177 --run-number "$NIGHTLY_RUN_NUMBER" \
178 --sha "$NIGHTLY_SHA" \
179 --github-output
180
181 echo "release_channel=preview" >> "$GITHUB_OUTPUT"
182 echo "cli_dist_tag=preview" >> "$GITHUB_OUTPUT"
183 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
184 echo "make_latest=false" >> "$GITHUB_OUTPUT"
185 else
186 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
187 raw="${DISPATCH_VERSION:-$NIGHTLY_VERSION}"
188 if [[ -z "$raw" ]]; then
189 echo "workflow_dispatch stable releases need a version input or a published nightly." >&2
190 exit 1
191 fi
192 else
193 raw="${GITHUB_REF_NAME}"
194 fi
195
196 version="${raw#v}"
197 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
198 echo "Invalid release version: $raw" >&2
199 exit 1
200 fi
201
202 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
203 echo "version=$version" >> "$GITHUB_OUTPUT"
204 echo "tag=v$version" >> "$GITHUB_OUTPUT"
205 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
206 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
207 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
208 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
209 echo "make_latest=true" >> "$GITHUB_OUTPUT"
210 else
211 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
212 echo "make_latest=false" >> "$GITHUB_OUTPUT"
213 fi
214 fi
215
216 - id: previous_tag
217 name: Resolve previous release tag
218 run: |
219 node scripts/resolve-previous-release-tag.ts \
220 --channel "${{ steps.release_meta.outputs.release_channel }}" \
221 --current-tag "${{ steps.release_meta.outputs.tag }}" \
222 --github-output
223
224 # Share only the verification results, not the large registry metadata cache.
225 - name: Upload dependency verification
226 continue-on-error: true
227 uses: actions/upload-artifact@v7
228 with:
229 name: release-dependency-verification
230 path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
231
232 quality:
233 name: Release quality checks
234 needs: [preflight]
235 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
236 runs-on: blacksmith-8vcpu-ubuntu-2404
237 timeout-minutes: 10
238 steps:
239 - name: Checkout
240 uses: actions/checkout@v6
241 with:
242 ref: ${{ needs.preflight.outputs.ref }}
243 sparse-checkout: |
244 /*
245 !/.repos/
246 sparse-checkout-cone-mode: false
247
248 - name: Setup dependencies
249 uses: ./.github/actions/setup-ci-deps
250 with:
251 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
252
253 - name: Ensure Electron runtime is installed
254 run: vp run --filter @t3tools/desktop ensure:electron
255
256 - name: Check
257 run: vp check
258
259 - name: Typecheck
260 run: vp run typecheck
261
262 # Keep tests on their own runners, using the same package split and server
263 # shards as CI (test, test_web, test_server in ci.yml). Keep the two in sync.
264 test:
265 name: Release tests
266 needs: [preflight]
267 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
268 runs-on: blacksmith-8vcpu-ubuntu-2404
269 timeout-minutes: 10
270 steps:
271 - name: Checkout
272 uses: actions/checkout@v6
273 with:
274 ref: ${{ needs.preflight.outputs.ref }}
275 sparse-checkout: |
276 /*
277 !/.repos/
278 sparse-checkout-cone-mode: false
279
280 - name: Setup dependencies
281 uses: ./.github/actions/setup-ci-deps
282 with:
283 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
284
285 - name: Ensure Electron runtime is installed
286 run: vp run --filter @t3tools/desktop ensure:electron
287
288 - uses: ./.github/actions/setup-apt-mirrors
289
290 - name: Install browser secret helper build libraries
291 run: |
292 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
293 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config build-essential
294
295 - name: Test
296 run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web' test
297
298 # Web browser tests time out when they share a runner with the other package
299 # suites: Chromium gets too little CPU and diff workers miss their 10s start budget.
300 test_web:
301 name: Release web tests
302 needs: [preflight]
303 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
304 runs-on: blacksmith-8vcpu-ubuntu-2404
305 timeout-minutes: 10
306 steps:
307 - name: Checkout
308 uses: actions/checkout@v6
309 with:
310 ref: ${{ needs.preflight.outputs.ref }}
311 sparse-checkout: |
312 /*
313 !/.repos/
314 sparse-checkout-cone-mode: false
315
316 - name: Setup dependencies
317 uses: ./.github/actions/setup-ci-deps
318 with:
319 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
320
321 - name: Resolve Playwright version
322 id: playwright_version
323 run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"
324
325 - name: Cache Chromium
326 id: chromium_cache
327 uses: actions/cache@v6
328 with:
329 path: ~/.cache/ms-playwright
330 key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
331
332 - name: Install Chromium for web browser tests
333 if: steps.chromium_cache.outputs.cache-hit != 'true'
334 run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium
335
336 - name: Install missing Chromium system dependencies
337 run: |
338 browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
339 test -n "$browser"
340 if ldd "$browser" | grep '=> not found'; then
341 node apps/web/node_modules/playwright/cli.js install-deps chromium
342 fi
343
344 - name: Test
345 run: vp run --filter @t3tools/web test
346
347 # Browser tests run source modules; this boots the production chunk graph.
348 - name: Boot the built web client
349 run: |
350 vp run --filter @t3tools/web build
351 node apps/web/scripts/verify-built-boot.ts
352
353 # Server test files run one at a time, so more small runners beat fewer big ones.
354 test_server:
355 name: Release server tests ${{ matrix.shard }}
356 needs: [preflight]
357 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
358 runs-on: blacksmith-4vcpu-ubuntu-2404
359 timeout-minutes: 10
360 strategy:
361 fail-fast: false
362 matrix:
363 shard: [1, 2, 3, 4, 5, 6, 7, 8]
364 steps:
365 - name: Checkout
366 uses: actions/checkout@v6
367 with:
368 ref: ${{ needs.preflight.outputs.ref }}
369 sparse-checkout: |
370 /*
371 !/.repos/
372 sparse-checkout-cone-mode: false
373
374 - name: Setup dependencies
375 uses: ./.github/actions/setup-ci-deps
376 with:
377 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
378
379 # No Electron setup here: `t3` (apps/server) has no Electron dependency
380 # and none of its tests touch the runtime. Only the non-server `test`
381 # job, which covers @t3tools/desktop, needs the download.
382 - name: Install Chromium for server browser integration tests
383 run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
384
385 - name: Test
386 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
387
388 relay_public_config:
389 name: Resolve T3 Connect public config
390 # Consumes only the release commit, not preflight's resolved version, so it
391 # runs alongside preflight instead of after it. The condition mirrors preflight's.
392 needs: [resolve_commit]
393 if: |
394 needs.resolve_commit.result == 'success' &&
395 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
396 runs-on: blacksmith-8vcpu-ubuntu-2404
397 timeout-minutes: 5
398 environment:
399 name: production
400 outputs:
401 clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
402 clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
403 clerk_cli_oauth_client_id: ${{ steps.public_config.outputs.clerk_cli_oauth_client_id }}
404 relay_url: ${{ steps.public_config.outputs.relay_url }}
405 env:
406 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
407 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
408 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
409 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
410 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
411 CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }}
412 CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }}
413 steps:
414 - name: Checkout
415 uses: actions/checkout@v6
416 with:
417 ref: ${{ needs.resolve_commit.outputs.ref }}
418 sparse-checkout: |
419 /*
420 !/.repos/
421 sparse-checkout-cone-mode: false
422
423 - name: Setup Vite+
424 uses: voidzero-dev/setup-vp@v1
425 with:
426 node-version-file: package.json
427 cache: true
428 run-install: |
429 args:
430 - --filter=t3code-relay...
431
432 # The deployed stack's outputs, read from Alchemy's state store without
433 # planning or applying. Select the backend explicitly to avoid loading
434 # the stack's unrelated provider credentials; suppress informational logs
435 # and strip the credential-refresh progress prefix before parsing JSON.
436 # Redacted values are persisted as
437 # {"__redacted__": "<value>"}; the token is masked before it is written.
438 - name: Read production relay tracing config
439 shell: bash
440 working-directory: infra/relay
441 run: |
442 set -euo pipefail
443 output="$(npx alchemy state read T3CodeRelay/prod/output --backend cloudflare --log-level error --no-input | sed -n '/^{/,$p')"
444 field() {
445 jq -er --arg key "$1" '.[$key] | if type == "object" then .__redacted__ else . end | select(. != null and . != "")' <<<"$output" \
446 || { echo "Relay stack output is missing $1" >&2; exit 1; }
447 }
448 url="$(field clientTracingUrl)"
449 dataset="$(field clientTracingDataset)"
450 token="$(field clientTracingToken)"
451 echo "::add-mask::$token"
452 {
453 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=$url"
454 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=$dataset"
455 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=$token"
456 } > "$RUNNER_TEMP/relay-client-tracing.env"
457
458 - name: Upload relay client tracing config
459 uses: actions/upload-artifact@v7
460 with:
461 name: relay-client-tracing-config
462 path: ${{ runner.temp }}/relay-client-tracing.env
463 if-no-files-found: error
464 retention-days: 1
465
466 - id: public_config
467 name: Resolve production relay public config
468 shell: bash
469 run: |
470 set -euo pipefail
471
472 relay_domain="${RELAY_DOMAIN:-}"
473 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
474 relay_domain="relay.$RELAY_API_ZONE_NAME"
475 fi
476 required=(
477 relay_domain
478 CLERK_PUBLISHABLE_KEY
479 CLERK_JWT_TEMPLATE
480 CLERK_CLI_OAUTH_CLIENT_ID
481 )
482 missing=()
483 for name in "${required[@]}"; do
484 if [[ -z "${!name:-}" ]]; then
485 missing+=("$name")
486 fi
487 done
488 if (( ${#missing[@]} > 0 )); then
489 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
490 exit 1
491 fi
492
493 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
494 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
495 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
496 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
497
498 # The platform-independent JS (server bundle, web client, Electron main) is
499 # built exactly once here and handed to every platform job as `js-bundle`.
500 # The relay/Clerk values are baked into the bundle, so they belong to this
501 # job rather than to the packaging jobs.
502 build_bundle:
503 name: Build JS bundle
504 # Same gating as relay_public_config: only the release commit is needed, so
505 # this runs alongside preflight. See the condition comment there.
506 needs: [preflight, relay_public_config]
507 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
508 runs-on: blacksmith-32vcpu-ubuntu-2404
509 timeout-minutes: 30
510 env:
511 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
512 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
513 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
514 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
515 steps:
516 - name: Checkout
517 uses: actions/checkout@v6
518 with:
519 ref: ${{ needs.preflight.outputs.ref }}
520 sparse-checkout: |
521 /*
522 !/.repos/
523 sparse-checkout-cone-mode: false
524
525 - name: Setup Vite+
526 uses: voidzero-dev/setup-vp@v1
527 with:
528 node-version-file: package.json
529 cache: true
530 run-install: false
531
532 # pnpm checks the lockfile and policy before reusing this result. A missing
533 # artifact leaves the cache empty, so installation runs the checks again.
534 - name: Download dependency verification
535 continue-on-error: true
536 uses: actions/download-artifact@v8
537 with:
538 name: release-dependency-verification
539 path: ${{ runner.temp }}/pnpm-metadata
540
541 - name: Install bundle dependencies
542 env:
543 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
544 run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts...
545
546 - name: Download relay client tracing config
547 uses: actions/download-artifact@v8
548 with:
549 name: relay-client-tracing-config
550 path: ${{ runner.temp }}/relay-client-tracing
551
552 - name: Load relay client tracing config
553 shell: bash
554 run: |
555 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
556 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
557 echo "::add-mask::$tracing_token"
558 cat "$config_path" >> "$GITHUB_ENV"
559
560 - name: Align package versions to release version
561 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
562
563 - uses: ./.github/actions/setup-apt-mirrors
564
565 # @t3tools/desktop#build compiles the Linux browser secret helper on a
566 # Linux host before packing, and that needs libsecret headers.
567 - name: Install browser secret helper build libraries
568 run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
569
570 # Runs t3#build (which depends on @t3tools/web#build) and
571 # @t3tools/desktop#build, so apps/server/dist holds the server bundle
572 # plus the web client and apps/desktop/dist-electron the Electron main.
573 # The release channel is already stable, nightly, or preview. Builds in
574 # other repositories report "dev" telemetry.
575 - name: Build JS bundle
576 env:
577 T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && needs.preflight.outputs.release_channel || 'dev' }}
578 run: vp run build:desktop
579
580 # Two paths under apps/ so the artifact root is apps/; consumers download
581 # into `apps` to restore both at their original locations.
582 - name: Upload JS bundle
583 uses: actions/upload-artifact@v7
584 with:
585 name: js-bundle
586 path: |
587 apps/server/dist
588 apps/desktop/dist-electron
589 if-no-files-found: error
590 retention-days: 1
591
592 # One job per platform and architecture (see release-desktop.yml), each
593 # gated only on the JS bundle. Windows targets build on Linux and run their
594 # native checks on a Windows runner of their own architecture.
595 # The Windows jobs also embed the same-arch Linux CLI archive as the WSL
596 # runtime; they wait for that artifact partway through instead of for the
597 # whole Linux job. Every job builds the desktop app; all but macOS x64 also
598 # build the CLI archive for their platform, so a target either ships fully or
599 # not at all.
600 desktop_mac_arm64:
601 name: Desktop macOS arm64
602 needs: [preflight, relay_public_config, build_bundle]
603 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
604 uses: ./.github/workflows/release-desktop.yml
605 secrets: inherit
606 with:
607 version: ${{ needs.preflight.outputs.version }}
608 ref: ${{ needs.preflight.outputs.ref }}
609 release_channel: ${{ needs.preflight.outputs.release_channel }}
610 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
611 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
612 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
613 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
614 label: macOS arm64
615 runner: blacksmith-12vcpu-macos-26
616 platform: mac
617 target: dmg
618 arch: arm64
619 rust_target: aarch64-apple-darwin
620 resource_key: darwin-arm64
621 cli_archive: true
622 launch_check: true
623
624 desktop_mac_x64:
625 name: Desktop macOS x64
626 needs: [preflight, relay_public_config, build_bundle]
627 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
628 uses: ./.github/workflows/release-desktop.yml
629 secrets: inherit
630 with:
631 version: ${{ needs.preflight.outputs.version }}
632 ref: ${{ needs.preflight.outputs.ref }}
633 release_channel: ${{ needs.preflight.outputs.release_channel }}
634 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
635 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
636 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
637 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
638 label: macOS x64
639 runner: blacksmith-12vcpu-macos-26
640 platform: mac
641 target: dmg
642 arch: x64
643 rust_target: x86_64-apple-darwin
644 resource_key: darwin-x64
645 # No CLI archive: Node single-executables are unsupported on x64 macOS
646 # (the SEA docs list macOS as arm64 only) and the built binary segfaults
647 # on start. The x64 desktop app is Electron and unaffected.
648 cli_archive: false
649
650 desktop_linux_x64:
651 name: Desktop Linux x64
652 needs: [preflight, relay_public_config, build_bundle]
653 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
654 uses: ./.github/workflows/release-desktop.yml
655 secrets: inherit
656 with:
657 version: ${{ needs.preflight.outputs.version }}
658 ref: ${{ needs.preflight.outputs.ref }}
659 release_channel: ${{ needs.preflight.outputs.release_channel }}
660 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
661 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
662 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
663 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
664 label: Linux x64
665 runner: blacksmith-32vcpu-ubuntu-2404
666 platform: linux
667 target: AppImage
668 arch: x64
669 rust_target: x86_64-unknown-linux-gnu
670 resource_key: linux-x64
671 cli_archive: true
672 launch_check: true
673
674 # node-pty has no Linux prebuild and compiles from source, so the arm64 app
675 # and archive are built on arm64 hardware rather than cross-built.
676 desktop_linux_arm64:
677 name: Desktop Linux arm64
678 needs: [preflight, relay_public_config, build_bundle]
679 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
680 uses: ./.github/workflows/release-desktop.yml
681 secrets: inherit
682 with:
683 version: ${{ needs.preflight.outputs.version }}
684 ref: ${{ needs.preflight.outputs.ref }}
685 release_channel: ${{ needs.preflight.outputs.release_channel }}
686 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
687 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
688 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
689 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
690 label: Linux arm64
691 runner: blacksmith-16vcpu-ubuntu-2404-arm
692 platform: linux
693 target: AppImage
694 arch: arm64
695 rust_target: aarch64-unknown-linux-gnu
696 resource_key: linux-arm64
697 cli_archive: true
698
699 # The Windows jobs start with the other platforms and wait for the same-arch
700 # Linux CLI archive after their other setup. Packaging is mostly CPU and
701 # small-file work, which Linux runners do faster than Windows ones, so both
702 # Windows targets build and sign on Linux and only the native checks run on
703 # Windows.
704 desktop_win_x64:
705 name: Desktop Windows x64
706 needs: [preflight, relay_public_config, build_bundle]
707 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
708 uses: ./.github/workflows/release-desktop.yml
709 secrets: inherit
710 with:
711 version: ${{ needs.preflight.outputs.version }}
712 ref: ${{ needs.preflight.outputs.ref }}
713 release_channel: ${{ needs.preflight.outputs.release_channel }}
714 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
715 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
716 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
717 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
718 label: Windows x64
719 runner: blacksmith-16vcpu-ubuntu-2404
720 verify_runner: windows-2025
721 platform: win
722 target: nsis
723 arch: x64
724 rust_target: x86_64-pc-windows-msvc
725 resource_key: win32-x64
726 cli_archive: true
727
728 desktop_win_arm64:
729 name: Desktop Windows arm64
730 needs: [preflight, relay_public_config, build_bundle]
731 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
732 uses: ./.github/workflows/release-desktop.yml
733 secrets: inherit
734 with:
735 version: ${{ needs.preflight.outputs.version }}
736 ref: ${{ needs.preflight.outputs.ref }}
737 release_channel: ${{ needs.preflight.outputs.release_channel }}
738 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
739 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
740 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
741 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
742 label: Windows arm64
743 runner: blacksmith-16vcpu-ubuntu-2404
744 verify_runner: windows-11-arm
745 platform: win
746 target: nsis
747 arch: arm64
748 rust_target: aarch64-pc-windows-msvc
749 resource_key: win32-arm64
750 cli_archive: true
751
752 release:
753 name: Publish GitHub Release
754 needs:
755 [
756 preflight,
757 relay_public_config,
758 quality,
759 test,
760 test_web,
761 test_server,
762 desktop_mac_arm64,
763 desktop_mac_x64,
764 desktop_linux_x64,
765 desktop_linux_arm64,
766 desktop_win_x64,
767 desktop_win_arm64,
768 ]
769 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.quality.result == 'success' && needs.test.result == 'success' && needs.test_web.result == 'success' && needs.test_server.result == 'success' && needs.desktop_mac_arm64.result == 'success' && needs.desktop_mac_x64.result == 'success' && needs.desktop_linux_x64.result == 'success' && needs.desktop_linux_arm64.result == 'success' && needs.desktop_win_x64.result == 'success' && needs.desktop_win_arm64.result == 'success' }}
770 runs-on: blacksmith-8vcpu-ubuntu-2404
771 timeout-minutes: 30
772 permissions:
773 contents: write
774 steps:
775 - name: Checkout
776 uses: actions/checkout@v6
777 with:
778 ref: ${{ needs.preflight.outputs.ref }}
779 sparse-checkout: |
780 /*
781 !/.repos/
782 sparse-checkout-cone-mode: false
783
784 - name: Setup Vite+
785 uses: voidzero-dev/setup-vp@v1
786 with:
787 node-version-file: package.json
788 cache: true
789 run-install: |
790 args:
791 - --filter=@t3tools/scripts...
792
793 - name: Download all desktop artifacts
794 uses: actions/download-artifact@v8
795 with:
796 pattern: desktop-*
797 merge-multiple: true
798 path: release-assets
799
800 - name: Download all CLI archives
801 uses: actions/download-artifact@v8
802 with:
803 pattern: cli-*
804 merge-multiple: true
805 path: release-assets
806
807 - name: Download internal Android APK for Nightly
808 if: needs.preflight.outputs.release_channel == 'nightly'
809 continue-on-error: true
810 env:
811 GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
812 PACKAGE_NAME: com.t3tools.t3code
813 APK_OUTPUT_DIR: release-assets
814 run: |
815 if [ -n "$GOOGLE_PLAY_SERVICE_ACCOUNT_JSON" ]; then
816 node .github/scripts/mirror-play-apk.cjs
817 fi
818
819 # Installers verify archives against this file, so it is written from the
820 # signed bytes that get uploaded, never from an earlier stage.
821 - name: Write CLI archive checksums
822 shell: bash
823 run: |
824 set -euo pipefail
825 cd release-assets
826 shopt -s nullglob
827 archives=(t3-*.tar.gz t3-*.zip)
828 if [[ ${#archives[@]} -eq 0 ]]; then
829 echo "No CLI archives were produced." >&2
830 exit 1
831 fi
832 sha256sum "${archives[@]}" > SHA256SUMS
833 cat SHA256SUMS
834
835 # The desktop build omits the publish config for preview versions, so
836 # electron-builder emits no updater manifests for them. Refuse to publish
837 # if one shows up anyway: a `latest*.yml` or `nightly*.yml` on a preview
838 # release is what would let a stable or nightly install update onto it.
839 - name: Refuse updater metadata on preview releases
840 if: needs.preflight.outputs.release_channel == 'preview'
841 shell: bash
842 run: |
843 set -euo pipefail
844 shopt -s nullglob extglob
845 # builder-debug.yml is electron-builder's config dump, not a feed.
846 updater_files=(release-assets/!(builder-debug).yml release-assets/*.blockmap)
847 if [[ ${#updater_files[@]} -ne 0 ]]; then
848 printf 'Preview releases must not carry updater metadata, found: %s\n' "${updater_files[*]}" >&2
849 exit 1
850 fi
851
852 # electron-updater reads one manifest per platform and channel and picks
853 # the file entry whose name carries the running arch, so the per-arch
854 # manifests the build jobs wrote are merged back into that one file.
855 - name: Merge macOS updater manifests
856 if: needs.preflight.outputs.release_channel != 'preview'
857 run: |
858 shopt -s nullglob
859 for x64_manifest in release-assets/*-mac-x64.yml; do
860 arm64_manifest="${x64_manifest%-x64.yml}.yml"
861 if [[ -f "$arm64_manifest" ]]; then
862 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
863 rm -f "$x64_manifest"
864 fi
865 done
866
867 - name: Merge Windows updater manifests
868 if: needs.preflight.outputs.release_channel != 'preview'
869 run: |
870 shopt -s nullglob
871 for x64_manifest in release-assets/*-win-x64.yml; do
872 arm64_manifest="${x64_manifest%-x64.yml}-arm64.yml"
873 merged_manifest="${x64_manifest%-win-x64.yml}.yml"
874 if [[ -f "$arm64_manifest" ]]; then
875 node scripts/merge-update-manifests.ts --platform win "$x64_manifest" "$arm64_manifest" "$merged_manifest"
876 rm -f "$x64_manifest" "$arm64_manifest"
877 else
878 mv "$x64_manifest" "$merged_manifest"
879 fi
880 done
881
882 # Updater manifests and blockmaps are what electron-updater consumes.
883 # They are only listed for channels an updater is meant to follow.
884 - id: release_files
885 name: Resolve release asset list
886 shell: bash
887 run: |
888 {
889 echo 'files<<EOF'
890 echo 'release-assets/*.dmg'
891 echo 'release-assets/*.zip'
892 echo 'release-assets/*.AppImage'
893 echo 'release-assets/*.deb'
894 echo 'release-assets/*.exe'
895 if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
896 echo 'release-assets/*.blockmap'
897 echo 'release-assets/*.yml'
898 fi
899 echo 'release-assets/*.tar.gz'
900 # Only list APKs when Play has a processed internal build available.
901 for apk in release-assets/*.apk; do
902 [[ -f "$apk" ]] && echo "$apk"
903 done
904 echo 'release-assets/SHA256SUMS'
905 echo 'EOF'
906 } >> "$GITHUB_OUTPUT"
907
908 # A preview release gets a warning instead of generated notes. Generated
909 # notes would list every commit since the previous preview, which is
910 # unmerged branch history no one should read as a changelog, and would
911 # make the release look like any other build to someone browsing the
912 # releases page.
913 - name: Write preview release notes
914 if: needs.preflight.outputs.release_channel == 'preview'
915 shell: bash
916 run: |
917 cat > release-notes.md <<'EOF'
918 > [!WARNING]
919 > **This is a preview build. Do not install it unless you know exactly why you are here.**
920 >
921 > 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.
922
923 Built from `${{ needs.preflight.outputs.ref }}`.
924 EOF
925
926 - name: Publish release
927 if: needs.preflight.outputs.previous_tag != ''
928 uses: softprops/action-gh-release@v3
929 with:
930 tag_name: ${{ needs.preflight.outputs.tag }}
931 target_commitish: ${{ needs.preflight.outputs.ref }}
932 name: ${{ needs.preflight.outputs.release_name }}
933 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
934 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
935 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
936 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
937 make_latest: ${{ needs.preflight.outputs.make_latest }}
938 files: ${{ steps.release_files.outputs.files }}
939 fail_on_unmatched_files: true
940 token: ${{ github.token }}
941
942 - name: Publish first release
943 if: needs.preflight.outputs.previous_tag == ''
944 uses: softprops/action-gh-release@v3
945 with:
946 tag_name: ${{ needs.preflight.outputs.tag }}
947 target_commitish: ${{ needs.preflight.outputs.ref }}
948 name: ${{ needs.preflight.outputs.release_name }}
949 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
950 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
951 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
952 make_latest: ${{ needs.preflight.outputs.make_latest }}
953 files: ${{ steps.release_files.outputs.files }}
954 fail_on_unmatched_files: true
955 token: ${{ github.token }}
956
957 # The `t3` npm package is a launcher that downloads this version's CLI
958 # archive from the GitHub Release, so it publishes only once that release
959 # exists. Preview publishes too, under the `preview` dist-tag, which
960 # nothing resolves unless asked for by name.
961 publish_cli:
962 name: Publish CLI to npm
963 needs: [preflight, release]
964 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
965 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
966 timeout-minutes: 15
967 permissions:
968 contents: read
969 id-token: write
970 steps:
971 - name: Checkout
972 uses: actions/checkout@v6
973 with:
974 ref: ${{ needs.preflight.outputs.ref }}
975 sparse-checkout: |
976 /*
977 !/.repos/
978 sparse-checkout-cone-mode: false
979
980 - name: Setup Vite+
981 uses: voidzero-dev/setup-vp@v1
982 with:
983 node-version-file: package.json
984 cache: true
985 run-install: |
986 args:
987 - --filter=t3...
988 - --filter=@t3tools/scripts...
989
990 - name: Build the npm launcher
991 run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages
992
993 - name: Publish the npm launcher
994 run: |
995 if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then
996 echo "::error::npm publish failed. Make sure package t3 has a trusted publisher registered for .github/workflows/release.yml (see docs/operations/release.md)." >&2
997 exit 1
998 fi
999
1000 publish_aur:
1001 name: Publish AUR package
1002 needs: [preflight, release]
1003 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1004 uses: ./.github/workflows/publish-aur.yml
1005 with:
1006 release_tag: ${{ needs.preflight.outputs.tag }}
1007 secrets:
1008 AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
1009
1010 # Vercel builds the hosted web app while the desktop jobs run. `--skip-domain`
1011 # keeps the custom domains (the channel and router domains) on the previous
1012 # deployment until deploy_web aliases them, after the GitHub Release. It does
1013 # still move the project's own *.vercel.app production hostname at build time.
1014 # That hostname sits behind Vercel SSO and is not a user channel, so the
1015 # npm-before-client order in docs/operations/release.md holds for users.
1016 build_web:
1017 name: Build hosted web app
1018 needs: [preflight, relay_public_config]
1019 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1020 runs-on: blacksmith-8vcpu-ubuntu-2404
1021 timeout-minutes: 10
1022 outputs:
1023 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1024 env:
1025 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
1026 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
1027 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
1028 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
1029 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1030 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1031 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1032 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1033 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1034 steps:
1035 - name: Checkout
1036 uses: actions/checkout@v6
1037 with:
1038 ref: ${{ needs.preflight.outputs.ref }}
1039 sparse-checkout: |
1040 /*
1041 !/.repos/
1042 sparse-checkout-cone-mode: false
1043
1044 - name: Setup Vite+
1045 uses: voidzero-dev/setup-vp@v1
1046 with:
1047 node-version-file: package.json
1048 cache: true
1049 run-install: |
1050 args:
1051 - --filter=@t3tools/scripts...
1052 - --filter=@t3tools/web...
1053
1054 - name: Download relay client tracing config
1055 uses: actions/download-artifact@v8
1056 with:
1057 name: relay-client-tracing-config
1058 path: ${{ runner.temp }}/relay-client-tracing
1059
1060 - name: Load relay client tracing config
1061 shell: bash
1062 run: |
1063 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
1064 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
1065 echo "::add-mask::$tracing_token"
1066 cat "$config_path" >> "$GITHUB_ENV"
1067
1068 - name: Align package versions to release version
1069 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
1070
1071 - name: Refresh release lockfile
1072 run: vp install --lockfile-only --ignore-scripts
1073
1074 - id: deploy
1075 name: Build staged deployment
1076 shell: bash
1077 run: |
1078 set -euo pipefail
1079
1080 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
1081 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
1082 exit 1
1083 fi
1084
1085 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1086 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1087 channel_name="latest"
1088 else
1089 channel_name="nightly"
1090 fi
1091
1092 echo "Building hosted web app for $channel_name channel."
1093 deployment_output="$(
1094 vp dlx vercel@53.1.1 deploy \
1095 --archive=tgz \
1096 --prod \
1097 --skip-domain \
1098 --yes \
1099 --token "$VERCEL_TOKEN" \
1100 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}" \
1101 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
1102 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
1103 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
1104 --build-env "T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=${T3CODE_CLERK_CLI_OAUTH_CLIENT_ID:-}" \
1105 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
1106 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
1107 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
1108 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
1109 --build-env "VITE_HOSTED_APP_URL=$router_url" \
1110 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
1111 )"
1112 printf '%s\n' "$deployment_output"
1113 # Vercel can print lockfile warnings to stdout before the deployment URL.
1114 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1115 if [[ "$deployment_url" == *$'\n'* ]]; then
1116 echo "Vercel returned multiple deployment URLs." >&2
1117 exit 1
1118 fi
1119 echo "Staged $deployment_url."
1120 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1121
1122 deploy_web:
1123 name: Deploy hosted web app
1124 needs: [preflight, build_web, release, publish_cli]
1125 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_web.result == 'success' && needs.release.result == 'success' && needs.publish_cli.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1126 runs-on: blacksmith-2vcpu-ubuntu-2404
1127 timeout-minutes: 10
1128 env:
1129 DEPLOYMENT_URL: ${{ needs.build_web.outputs.deployment_url }}
1130 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1131 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1132 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1133 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1134 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
1135 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
1136 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1137 steps:
1138 - name: Checkout
1139 uses: actions/checkout@v6
1140 with:
1141 ref: ${{ needs.preflight.outputs.ref }}
1142 sparse-checkout: |
1143 /*
1144 !/.repos/
1145 sparse-checkout-cone-mode: false
1146
1147 - name: Setup Vite+
1148 uses: voidzero-dev/setup-vp@v1
1149 with:
1150 node-version-file: package.json
1151 cache: false
1152 run-install: false
1153
1154 - name: Alias channel
1155 shell: bash
1156 run: |
1157 set -euo pipefail
1158
1159 if [[ -z "$DEPLOYMENT_URL" ]]; then
1160 echo "Build hosted web app did not report a deployment URL." >&2
1161 exit 1
1162 fi
1163
1164 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1165 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
1166 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
1167 router_domain="${router_url#http://}"
1168 router_domain="${router_domain#https://}"
1169 router_domain="${router_domain%%/*}"
1170
1171 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1172 channel_domain="$latest_domain"
1173 channel_name="latest"
1174 else
1175 channel_domain="$nightly_domain"
1176 channel_name="nightly"
1177 fi
1178
1179 vercel_scope_args=(--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}")
1180
1181 echo "Aliasing $DEPLOYMENT_URL to $channel_domain."
1182 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$channel_domain" \
1183 --token "$VERCEL_TOKEN" \
1184 "${vercel_scope_args[@]}"
1185
1186 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
1187 echo "Aliasing $DEPLOYMENT_URL to router domain $router_domain."
1188 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$router_domain" \
1189 --token "$VERCEL_TOKEN" \
1190 "${vercel_scope_args[@]}"
1191 fi
1192
1193 # Same split as the web app: build a production deployment early, then
1194 # promote it to t3.codes once the release it links to exists. As above, the
1195 # project's own *.vercel.app hostname moves at build time.
1196 build_marketing:
1197 name: Build marketing site
1198 needs: [preflight]
1199 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1200 runs-on: blacksmith-8vcpu-ubuntu-2404
1201 timeout-minutes: 10
1202 outputs:
1203 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1204 project_id: ${{ steps.deploy.outputs.project_id }}
1205 env:
1206 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1207 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1208 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1209 steps:
1210 - name: Checkout
1211 uses: actions/checkout@v6
1212 with:
1213 ref: ${{ needs.preflight.outputs.ref }}
1214 sparse-checkout: |
1215 /*
1216 !/.repos/
1217 sparse-checkout-cone-mode: false
1218
1219 - name: Setup Vite+
1220 uses: voidzero-dev/setup-vp@v1
1221 with:
1222 node-version-file: package.json
1223 cache: true
1224 run-install: |
1225 args:
1226 - --filter=@t3tools/marketing...
1227
1228 - id: deploy
1229 name: Build staged deployment
1230 shell: bash
1231 run: |
1232 set -euo pipefail
1233
1234 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" ]]; then
1235 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID." >&2
1236 exit 1
1237 fi
1238
1239 VERCEL_PROJECT_ID="$(
1240 curl --fail --silent --show-error \
1241 --header "Authorization: Bearer $VERCEL_TOKEN" \
1242 "https://api.vercel.com/v9/projects/t3code-marketing?teamId=$VERCEL_ORG_ID" \
1243 | jq --exit-status --raw-output '.id'
1244 )"
1245 export VERCEL_PROJECT_ID
1246
1247 deployment_output="$(
1248 vp dlx vercel@53.1.1 deploy \
1249 --archive=tgz \
1250 --prod \
1251 --skip-domain \
1252 --yes \
1253 --token "$VERCEL_TOKEN" \
1254 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1255 )"
1256 printf '%s\n' "$deployment_output"
1257 # Vercel can print lockfile warnings to stdout before the deployment URL.
1258 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1259 if [[ "$deployment_url" == *$'\n'* ]]; then
1260 echo "Vercel returned multiple deployment URLs." >&2
1261 exit 1
1262 fi
1263 echo "Staged $deployment_url."
1264 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1265 echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"
1266
1267 deploy_marketing:
1268 name: Deploy marketing site
1269 needs: [preflight, build_marketing, release]
1270 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_marketing.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1271 runs-on: blacksmith-2vcpu-ubuntu-2404
1272 timeout-minutes: 10
1273 env:
1274 DEPLOYMENT_URL: ${{ needs.build_marketing.outputs.deployment_url }}
1275 VERCEL_PROJECT_ID: ${{ needs.build_marketing.outputs.project_id }}
1276 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1277 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1278 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1279 steps:
1280 - name: Checkout
1281 uses: actions/checkout@v6
1282 with:
1283 ref: ${{ needs.preflight.outputs.ref }}
1284 sparse-checkout: |
1285 /*
1286 !/.repos/
1287 sparse-checkout-cone-mode: false
1288
1289 - name: Setup Vite+
1290 uses: voidzero-dev/setup-vp@v1
1291 with:
1292 node-version-file: package.json
1293 cache: false
1294 run-install: false
1295
1296 - name: Promote marketing site
1297 shell: bash
1298 run: |
1299 set -euo pipefail
1300
1301 if [[ -z "$DEPLOYMENT_URL" ]]; then
1302 echo "Build marketing site did not report a deployment URL." >&2
1303 exit 1
1304 fi
1305
1306 echo "Promoting $DEPLOYMENT_URL."
1307 vp dlx vercel@53.1.1 promote "$DEPLOYMENT_URL" \
1308 --yes \
1309 --token "$VERCEL_TOKEN" \
1310 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1311
1312 finalize:
1313 name: Finalize release
1314 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
1315 needs: [preflight, release]
1316 runs-on: blacksmith-8vcpu-ubuntu-2404
1317 timeout-minutes: 10
1318 steps:
1319 - id: app_token
1320 name: Mint release app token
1321 uses: actions/create-github-app-token@v2
1322 with:
1323 app-id: ${{ secrets.RELEASE_APP_ID }}
1324 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
1325 owner: ${{ github.repository_owner }}
1326
1327 - name: Checkout
1328 uses: actions/checkout@v6
1329 with:
1330 ref: main
1331 fetch-depth: 0
1332 token: ${{ steps.app_token.outputs.token }}
1333 persist-credentials: true
1334 sparse-checkout: |
1335 /*
1336 !/.repos/
1337 sparse-checkout-cone-mode: false
1338
1339 - id: app_bot
1340 name: Resolve GitHub App bot identity
1341 env:
1342 GH_TOKEN: ${{ steps.app_token.outputs.token }}
1343 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
1344 run: |
1345 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
1346 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
1347 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
1348
1349 - name: Setup Vite+
1350 uses: voidzero-dev/setup-vp@v1
1351 with:
1352 node-version-file: package.json
1353 cache: true
1354 run-install: |
1355 args:
1356 - --filter=@t3tools/scripts...
1357 - --filter=@t3tools/oxlint-plugin-t3code...
1358
1359 - id: update_versions
1360 name: Update version strings
1361 env:
1362 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
1363 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
1364
1365 - name: Format package.json files
1366 if: steps.update_versions.outputs.changed == 'true'
1367 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
1368
1369 - name: Refresh lockfile
1370 if: steps.update_versions.outputs.changed == 'true'
1371 run: vp install --lockfile-only --ignore-scripts
1372
1373 - name: Commit and push version bump
1374 if: steps.update_versions.outputs.changed == 'true'
1375 shell: bash
1376 env:
1377 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1378 run: |
1379 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
1380 echo "No version changes to commit."
1381 exit 0
1382 fi
1383
1384 git config user.name "${{ steps.app_bot.outputs.name }}"
1385 git config user.email "${{ steps.app_bot.outputs.email }}"
1386
1387 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
1388 git commit -m "chore(release): prepare $RELEASE_TAG"
1389 git push origin HEAD:main
1390
1391 announce_discord:
1392 name: Announce release on Discord
1393 if: |
1394 always() && !cancelled() &&
1395 needs.preflight.result == 'success' &&
1396 needs.preflight.outputs.release_channel != 'preview' &&
1397 needs.relay_public_config.result == 'success' &&
1398 needs.release.result == 'success' &&
1399 needs.deploy_web.result == 'success' &&
1400 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
1401 needs: [preflight, relay_public_config, release, deploy_web, finalize]
1402 runs-on: blacksmith-8vcpu-ubuntu-2404
1403 timeout-minutes: 10
1404 steps:
1405 - name: Checkout
1406 uses: actions/checkout@v6
1407 with:
1408 ref: ${{ needs.preflight.outputs.ref }}
1409 sparse-checkout: |
1410 /*
1411 !/.repos/
1412 sparse-checkout-cone-mode: false
1413
1414 - name: Setup Vite+
1415 uses: voidzero-dev/setup-vp@v1
1416 with:
1417 node-version-file: package.json
1418 cache: true
1419 run-install: |
1420 args:
1421 - --filter=@t3tools/scripts...
1422
1423 - name: Read published release notes
1424 if: needs.preflight.outputs.is_prerelease == 'true'
1425 continue-on-error: true
1426 env:
1427 GH_TOKEN: ${{ github.token }}
1428 GH_REPO: ${{ github.repository }}
1429 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1430 RELEASE_CHANNEL: ${{ needs.preflight.outputs.release_channel }}
1431 run: |
1432 if [ "$RELEASE_CHANNEL" = 'nightly' ]; then
1433 if ! gh release view "$RELEASE_TAG" --json body --jq '.body // ""' > "$RUNNER_TEMP/discord-release-notes.md"; then
1434 : > "$RUNNER_TEMP/discord-release-notes.md"
1435 echo '::warning::Could not read published release notes; announcing without a changelog.'
1436 fi
1437 else
1438 : > "$RUNNER_TEMP/discord-release-notes.md"
1439 fi
1440
1441 - name: Announce prerelease on Discord
1442 if: needs.preflight.outputs.is_prerelease == 'true'
1443 continue-on-error: true
1444 env:
1445 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
1446 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1447 run: |
1448 node scripts/notify-discord-release.ts prerelease \
1449 --role-id "$DISCORD_MENTION_ROLE_ID" \
1450 --release-name "${{ needs.preflight.outputs.release_name }}" \
1451 --release-version "${{ needs.preflight.outputs.version }}" \
1452 --tag "${{ needs.preflight.outputs.tag }}" \
1453 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}" \
1454 --release-notes-file "$RUNNER_TEMP/discord-release-notes.md"
1455
1456 - name: Announce latest release on Discord
1457 if: needs.preflight.outputs.make_latest == 'true'
1458 continue-on-error: true
1459 env:
1460 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
1461 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1462 run: |
1463 node scripts/notify-discord-release.ts latest \
1464 --role-id "$DISCORD_MENTION_ROLE_ID" \
1465 --release-name "${{ needs.preflight.outputs.release_name }}" \
1466 --release-version "${{ needs.preflight.outputs.version }}" \
1467 --tag "${{ needs.preflight.outputs.tag }}" \
1468 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"