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 dependencies
424 uses: ./.github/actions/setup-ci-deps
425 with:
426 install-args: --filter=t3code-relay...
427
428 # The deployed stack's outputs, read from Alchemy's state store without
429 # planning or applying. Select the backend explicitly to avoid loading
430 # the stack's unrelated provider credentials; suppress informational logs
431 # and strip the credential-refresh progress prefix before parsing JSON.
432 # Redacted values are persisted as
433 # {"__redacted__": "<value>"}; the token is masked before it is written.
434 - name: Read production relay tracing config
435 shell: bash
436 working-directory: infra/relay
437 run: |
438 set -euo pipefail
439 output="$(npx alchemy state read T3CodeRelay/prod/output --backend cloudflare --log-level error --no-input | sed -n '/^{/,$p')"
440 field() {
441 jq -er --arg key "$1" '.[$key] | if type == "object" then .__redacted__ else . end | select(. != null and . != "")' <<<"$output" \
442 || { echo "Relay stack output is missing $1" >&2; exit 1; }
443 }
444 url="$(field clientTracingUrl)"
445 dataset="$(field clientTracingDataset)"
446 token="$(field clientTracingToken)"
447 echo "::add-mask::$token"
448 {
449 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=$url"
450 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=$dataset"
451 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=$token"
452 } > "$RUNNER_TEMP/relay-client-tracing.env"
453
454 - name: Upload relay client tracing config
455 uses: actions/upload-artifact@v7
456 with:
457 name: relay-client-tracing-config
458 path: ${{ runner.temp }}/relay-client-tracing.env
459 if-no-files-found: error
460 retention-days: 1
461
462 - id: public_config
463 name: Resolve production relay public config
464 shell: bash
465 run: |
466 set -euo pipefail
467
468 relay_domain="${RELAY_DOMAIN:-}"
469 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
470 relay_domain="relay.$RELAY_API_ZONE_NAME"
471 fi
472 required=(
473 relay_domain
474 CLERK_PUBLISHABLE_KEY
475 CLERK_JWT_TEMPLATE
476 CLERK_CLI_OAUTH_CLIENT_ID
477 )
478 missing=()
479 for name in "${required[@]}"; do
480 if [[ -z "${!name:-}" ]]; then
481 missing+=("$name")
482 fi
483 done
484 if (( ${#missing[@]} > 0 )); then
485 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
486 exit 1
487 fi
488
489 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
490 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
491 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
492 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
493
494 # The platform-independent JS (server bundle, web client, Electron main) is
495 # built exactly once here and handed to every platform job as `js-bundle`.
496 # The relay/Clerk values are baked into the bundle, so they belong to this
497 # job rather than to the packaging jobs.
498 build_bundle:
499 name: Build JS bundle
500 # Same gating as relay_public_config: only the release commit is needed, so
501 # this runs alongside preflight. See the condition comment there.
502 needs: [preflight, relay_public_config]
503 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
504 runs-on: blacksmith-32vcpu-ubuntu-2404
505 timeout-minutes: 30
506 env:
507 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
508 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
509 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
510 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
511 steps:
512 - name: Checkout
513 uses: actions/checkout@v6
514 with:
515 ref: ${{ needs.preflight.outputs.ref }}
516 sparse-checkout: |
517 /*
518 !/.repos/
519 sparse-checkout-cone-mode: false
520
521 # pnpm checks the lockfile and policy before reusing this result. A missing
522 # artifact leaves the cache empty, so installation runs the checks again.
523 - name: Download dependency verification
524 continue-on-error: true
525 uses: actions/download-artifact@v8
526 with:
527 name: release-dependency-verification
528 path: ${{ runner.temp }}/pnpm-metadata
529
530 - name: Setup dependencies
531 uses: ./.github/actions/setup-ci-deps
532 with:
533 install-args: --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts...
534 env:
535 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
536
537 - name: Download relay client tracing config
538 uses: actions/download-artifact@v8
539 with:
540 name: relay-client-tracing-config
541 path: ${{ runner.temp }}/relay-client-tracing
542
543 - name: Load relay client tracing config
544 shell: bash
545 run: |
546 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
547 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
548 echo "::add-mask::$tracing_token"
549 cat "$config_path" >> "$GITHUB_ENV"
550
551 - name: Align package versions to release version
552 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
553
554 - uses: ./.github/actions/setup-apt-mirrors
555
556 # @t3tools/desktop#build compiles the Linux browser secret helper on a
557 # Linux host before packing, and that needs libsecret headers.
558 - name: Install browser secret helper build libraries
559 run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
560
561 # Runs t3#build (which depends on @t3tools/web#build) and
562 # @t3tools/desktop#build, so apps/server/dist holds the server bundle
563 # plus the web client and apps/desktop/dist-electron the Electron main.
564 # The release channel is already stable, nightly, or preview. Builds in
565 # other repositories report "dev" telemetry.
566 - name: Build JS bundle
567 env:
568 T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && needs.preflight.outputs.release_channel || 'dev' }}
569 run: vp run build:desktop
570
571 # Two paths under apps/ so the artifact root is apps/; consumers download
572 # into `apps` to restore both at their original locations.
573 - name: Upload JS bundle
574 uses: actions/upload-artifact@v7
575 with:
576 name: js-bundle
577 path: |
578 apps/server/dist
579 apps/desktop/dist-electron
580 if-no-files-found: error
581 retention-days: 1
582
583 # One job per platform and architecture (see release-desktop.yml), each
584 # gated only on the JS bundle. Windows targets build on Linux and run their
585 # native checks on a Windows runner of their own architecture.
586 # The Windows jobs also embed the same-arch Linux CLI archive as the WSL
587 # runtime; they wait for that artifact partway through instead of for the
588 # whole Linux job. Every job builds the desktop app; all but macOS x64 also
589 # build the CLI archive for their platform, so a target either ships fully or
590 # not at all.
591 desktop_mac_arm64:
592 name: Desktop macOS arm64
593 needs: [preflight, relay_public_config, build_bundle]
594 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
595 uses: ./.github/workflows/release-desktop.yml
596 secrets: inherit
597 with:
598 version: ${{ needs.preflight.outputs.version }}
599 ref: ${{ needs.preflight.outputs.ref }}
600 release_channel: ${{ needs.preflight.outputs.release_channel }}
601 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
602 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
603 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
604 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
605 label: macOS arm64
606 runner: blacksmith-12vcpu-macos-26
607 platform: mac
608 target: dmg
609 arch: arm64
610 rust_target: aarch64-apple-darwin
611 resource_key: darwin-arm64
612 cli_archive: true
613 launch_check: true
614
615 desktop_mac_x64:
616 name: Desktop macOS x64
617 needs: [preflight, relay_public_config, build_bundle]
618 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
619 uses: ./.github/workflows/release-desktop.yml
620 secrets: inherit
621 with:
622 version: ${{ needs.preflight.outputs.version }}
623 ref: ${{ needs.preflight.outputs.ref }}
624 release_channel: ${{ needs.preflight.outputs.release_channel }}
625 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
626 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
627 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
628 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
629 label: macOS x64
630 runner: blacksmith-12vcpu-macos-26
631 platform: mac
632 target: dmg
633 arch: x64
634 rust_target: x86_64-apple-darwin
635 resource_key: darwin-x64
636 # No CLI archive: Node single-executables are unsupported on x64 macOS
637 # (the SEA docs list macOS as arm64 only) and the built binary segfaults
638 # on start. The x64 desktop app is Electron and unaffected.
639 cli_archive: false
640
641 desktop_linux_x64:
642 name: Desktop Linux x64
643 needs: [preflight, relay_public_config, build_bundle]
644 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
645 uses: ./.github/workflows/release-desktop.yml
646 secrets: inherit
647 with:
648 version: ${{ needs.preflight.outputs.version }}
649 ref: ${{ needs.preflight.outputs.ref }}
650 release_channel: ${{ needs.preflight.outputs.release_channel }}
651 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
652 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
653 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
654 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
655 label: Linux x64
656 runner: blacksmith-32vcpu-ubuntu-2404
657 platform: linux
658 target: AppImage
659 arch: x64
660 rust_target: x86_64-unknown-linux-gnu
661 resource_key: linux-x64
662 cli_archive: true
663 launch_check: true
664
665 # node-pty has no Linux prebuild and compiles from source, so the arm64 app
666 # and archive are built on arm64 hardware rather than cross-built.
667 desktop_linux_arm64:
668 name: Desktop Linux arm64
669 needs: [preflight, relay_public_config, build_bundle]
670 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
671 uses: ./.github/workflows/release-desktop.yml
672 secrets: inherit
673 with:
674 version: ${{ needs.preflight.outputs.version }}
675 ref: ${{ needs.preflight.outputs.ref }}
676 release_channel: ${{ needs.preflight.outputs.release_channel }}
677 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
678 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
679 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
680 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
681 label: Linux arm64
682 runner: blacksmith-16vcpu-ubuntu-2404-arm
683 platform: linux
684 target: AppImage
685 arch: arm64
686 rust_target: aarch64-unknown-linux-gnu
687 resource_key: linux-arm64
688 cli_archive: true
689
690 # The Windows jobs start with the other platforms and wait for the same-arch
691 # Linux CLI archive after their other setup. Packaging is mostly CPU and
692 # small-file work, which Linux runners do faster than Windows ones, so both
693 # Windows targets build and sign on Linux and only the native checks run on
694 # Windows.
695 desktop_win_x64:
696 name: Desktop Windows x64
697 needs: [preflight, relay_public_config, build_bundle]
698 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
699 uses: ./.github/workflows/release-desktop.yml
700 secrets: inherit
701 with:
702 version: ${{ needs.preflight.outputs.version }}
703 ref: ${{ needs.preflight.outputs.ref }}
704 release_channel: ${{ needs.preflight.outputs.release_channel }}
705 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
706 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
707 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
708 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
709 label: Windows x64
710 runner: blacksmith-16vcpu-ubuntu-2404
711 verify_runner: windows-2025
712 platform: win
713 target: nsis
714 arch: x64
715 rust_target: x86_64-pc-windows-msvc
716 resource_key: win32-x64
717 cli_archive: true
718
719 desktop_win_arm64:
720 name: Desktop Windows arm64
721 needs: [preflight, relay_public_config, build_bundle]
722 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
723 uses: ./.github/workflows/release-desktop.yml
724 secrets: inherit
725 with:
726 version: ${{ needs.preflight.outputs.version }}
727 ref: ${{ needs.preflight.outputs.ref }}
728 release_channel: ${{ needs.preflight.outputs.release_channel }}
729 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
730 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
731 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
732 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
733 label: Windows arm64
734 runner: blacksmith-16vcpu-ubuntu-2404
735 verify_runner: windows-11-arm
736 platform: win
737 target: nsis
738 arch: arm64
739 rust_target: aarch64-pc-windows-msvc
740 resource_key: win32-arm64
741 cli_archive: true
742
743 release:
744 name: Publish GitHub Release
745 needs:
746 [
747 preflight,
748 relay_public_config,
749 quality,
750 test,
751 test_web,
752 test_server,
753 desktop_mac_arm64,
754 desktop_mac_x64,
755 desktop_linux_x64,
756 desktop_linux_arm64,
757 desktop_win_x64,
758 desktop_win_arm64,
759 ]
760 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' }}
761 runs-on: blacksmith-8vcpu-ubuntu-2404
762 timeout-minutes: 30
763 permissions:
764 contents: write
765 steps:
766 - name: Checkout
767 uses: actions/checkout@v6
768 with:
769 ref: ${{ needs.preflight.outputs.ref }}
770 sparse-checkout: |
771 /*
772 !/.repos/
773 sparse-checkout-cone-mode: false
774
775 - name: Setup dependencies
776 uses: ./.github/actions/setup-ci-deps
777 with:
778 install-args: --filter=@t3tools/scripts...
779
780 - name: Download all desktop artifacts
781 uses: actions/download-artifact@v8
782 with:
783 pattern: desktop-*
784 merge-multiple: true
785 path: release-assets
786
787 - name: Download all CLI archives
788 uses: actions/download-artifact@v8
789 with:
790 pattern: cli-*
791 merge-multiple: true
792 path: release-assets
793
794 - name: Download internal Android APK for Nightly
795 if: needs.preflight.outputs.release_channel == 'nightly'
796 continue-on-error: true
797 env:
798 GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
799 PACKAGE_NAME: com.t3tools.t3code
800 APK_OUTPUT_DIR: release-assets
801 run: |
802 if [ -n "$GOOGLE_PLAY_SERVICE_ACCOUNT_JSON" ]; then
803 node .github/scripts/mirror-play-apk.cjs
804 fi
805
806 # Installers verify archives against this file, so it is written from the
807 # signed bytes that get uploaded, never from an earlier stage.
808 - name: Write CLI archive checksums
809 shell: bash
810 run: |
811 set -euo pipefail
812 cd release-assets
813 shopt -s nullglob
814 archives=(t3-*.tar.gz t3-*.zip)
815 if [[ ${#archives[@]} -eq 0 ]]; then
816 echo "No CLI archives were produced." >&2
817 exit 1
818 fi
819 sha256sum "${archives[@]}" > SHA256SUMS
820 cat SHA256SUMS
821
822 # The desktop build omits the publish config for preview versions, so
823 # electron-builder emits no updater manifests for them. Refuse to publish
824 # if one shows up anyway: a `latest*.yml` or `nightly*.yml` on a preview
825 # release is what would let a stable or nightly install update onto it.
826 - name: Refuse updater metadata on preview releases
827 if: needs.preflight.outputs.release_channel == 'preview'
828 shell: bash
829 run: |
830 set -euo pipefail
831 shopt -s nullglob extglob
832 # builder-debug.yml is electron-builder's config dump, not a feed.
833 updater_files=(release-assets/!(builder-debug).yml release-assets/*.blockmap)
834 if [[ ${#updater_files[@]} -ne 0 ]]; then
835 printf 'Preview releases must not carry updater metadata, found: %s\n' "${updater_files[*]}" >&2
836 exit 1
837 fi
838
839 # electron-updater reads one manifest per platform and channel and picks
840 # the file entry whose name carries the running arch, so the per-arch
841 # manifests the build jobs wrote are merged back into that one file.
842 - name: Merge macOS updater manifests
843 if: needs.preflight.outputs.release_channel != 'preview'
844 run: |
845 shopt -s nullglob
846 for x64_manifest in release-assets/*-mac-x64.yml; do
847 arm64_manifest="${x64_manifest%-x64.yml}.yml"
848 if [[ -f "$arm64_manifest" ]]; then
849 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
850 rm -f "$x64_manifest"
851 fi
852 done
853
854 - name: Merge Windows updater manifests
855 if: needs.preflight.outputs.release_channel != 'preview'
856 run: |
857 shopt -s nullglob
858 for x64_manifest in release-assets/*-win-x64.yml; do
859 arm64_manifest="${x64_manifest%-x64.yml}-arm64.yml"
860 merged_manifest="${x64_manifest%-win-x64.yml}.yml"
861 if [[ -f "$arm64_manifest" ]]; then
862 node scripts/merge-update-manifests.ts --platform win "$x64_manifest" "$arm64_manifest" "$merged_manifest"
863 rm -f "$x64_manifest" "$arm64_manifest"
864 else
865 mv "$x64_manifest" "$merged_manifest"
866 fi
867 done
868
869 # Updater manifests and blockmaps are what electron-updater consumes.
870 # They are only listed for channels an updater is meant to follow.
871 - id: release_files
872 name: Resolve release asset list
873 shell: bash
874 run: |
875 {
876 echo 'files<<EOF'
877 echo 'release-assets/*.dmg'
878 echo 'release-assets/*.zip'
879 echo 'release-assets/*.AppImage'
880 echo 'release-assets/*.deb'
881 echo 'release-assets/*.exe'
882 if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
883 echo 'release-assets/*.blockmap'
884 echo 'release-assets/*.yml'
885 fi
886 echo 'release-assets/*.tar.gz'
887 # Only list APKs when Play has a processed internal build available.
888 for apk in release-assets/*.apk; do
889 [[ -f "$apk" ]] && echo "$apk"
890 done
891 echo 'release-assets/SHA256SUMS'
892 echo 'EOF'
893 } >> "$GITHUB_OUTPUT"
894
895 # A preview release gets a warning instead of generated notes. Generated
896 # notes would list every commit since the previous preview, which is
897 # unmerged branch history no one should read as a changelog, and would
898 # make the release look like any other build to someone browsing the
899 # releases page.
900 - name: Write preview release notes
901 if: needs.preflight.outputs.release_channel == 'preview'
902 shell: bash
903 run: |
904 cat > release-notes.md <<'EOF'
905 > [!WARNING]
906 > **This is a preview build. Do not install it unless you know exactly why you are here.**
907 >
908 > 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.
909
910 Built from `${{ needs.preflight.outputs.ref }}`.
911 EOF
912
913 - name: Publish release
914 if: needs.preflight.outputs.previous_tag != ''
915 uses: softprops/action-gh-release@v3
916 with:
917 tag_name: ${{ needs.preflight.outputs.tag }}
918 target_commitish: ${{ needs.preflight.outputs.ref }}
919 name: ${{ needs.preflight.outputs.release_name }}
920 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
921 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
922 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
923 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
924 make_latest: ${{ needs.preflight.outputs.make_latest }}
925 files: ${{ steps.release_files.outputs.files }}
926 fail_on_unmatched_files: true
927 token: ${{ github.token }}
928
929 - name: Publish first release
930 if: needs.preflight.outputs.previous_tag == ''
931 uses: softprops/action-gh-release@v3
932 with:
933 tag_name: ${{ needs.preflight.outputs.tag }}
934 target_commitish: ${{ needs.preflight.outputs.ref }}
935 name: ${{ needs.preflight.outputs.release_name }}
936 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
937 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
938 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
939 make_latest: ${{ needs.preflight.outputs.make_latest }}
940 files: ${{ steps.release_files.outputs.files }}
941 fail_on_unmatched_files: true
942 token: ${{ github.token }}
943
944 # The `t3` npm package is a launcher that downloads this version's CLI
945 # archive from the GitHub Release, so it publishes only once that release
946 # exists. Preview publishes too, under the `preview` dist-tag, which
947 # nothing resolves unless asked for by name.
948 publish_cli:
949 name: Publish CLI to npm
950 needs: [preflight, release]
951 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
952 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
953 timeout-minutes: 15
954 permissions:
955 contents: read
956 id-token: write
957 steps:
958 - name: Checkout
959 uses: actions/checkout@v6
960 with:
961 ref: ${{ needs.preflight.outputs.ref }}
962 sparse-checkout: |
963 /*
964 !/.repos/
965 sparse-checkout-cone-mode: false
966
967 - name: Setup dependencies
968 uses: ./.github/actions/setup-ci-deps
969 with:
970 install-args: --filter=t3... --filter=@t3tools/scripts...
971
972 - name: Build the npm launcher
973 run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages
974
975 - name: Publish the npm launcher
976 run: |
977 if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then
978 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
979 exit 1
980 fi
981
982 publish_aur:
983 name: Publish AUR package
984 needs: [preflight, release]
985 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
986 uses: ./.github/workflows/publish-aur.yml
987 with:
988 release_tag: ${{ needs.preflight.outputs.tag }}
989 secrets:
990 AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
991
992 # Vercel builds the hosted web app while the desktop jobs run. `--skip-domain`
993 # keeps the custom domains (the channel and router domains) on the previous
994 # deployment until deploy_web aliases them, after the GitHub Release. It does
995 # still move the project's own *.vercel.app production hostname at build time.
996 # That hostname sits behind Vercel SSO and is not a user channel, so the
997 # npm-before-client order in docs/operations/release.md holds for users.
998 build_web:
999 name: Build hosted web app
1000 needs: [preflight, relay_public_config]
1001 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1002 runs-on: blacksmith-8vcpu-ubuntu-2404
1003 timeout-minutes: 10
1004 outputs:
1005 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1006 env:
1007 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
1008 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
1009 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
1010 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
1011 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1012 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1013 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1014 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1015 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1016 steps:
1017 - name: Checkout
1018 uses: actions/checkout@v6
1019 with:
1020 ref: ${{ needs.preflight.outputs.ref }}
1021 sparse-checkout: |
1022 /*
1023 !/.repos/
1024 sparse-checkout-cone-mode: false
1025
1026 - name: Setup dependencies
1027 uses: ./.github/actions/setup-ci-deps
1028 with:
1029 install-args: --filter=@t3tools/scripts... --filter=@t3tools/web...
1030
1031 - name: Download relay client tracing config
1032 uses: actions/download-artifact@v8
1033 with:
1034 name: relay-client-tracing-config
1035 path: ${{ runner.temp }}/relay-client-tracing
1036
1037 - name: Load relay client tracing config
1038 shell: bash
1039 run: |
1040 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
1041 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
1042 echo "::add-mask::$tracing_token"
1043 cat "$config_path" >> "$GITHUB_ENV"
1044
1045 - name: Align package versions to release version
1046 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
1047
1048 - name: Refresh release lockfile
1049 run: vp install --lockfile-only --ignore-scripts
1050
1051 - id: deploy
1052 name: Build staged deployment
1053 shell: bash
1054 run: |
1055 set -euo pipefail
1056
1057 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
1058 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
1059 exit 1
1060 fi
1061
1062 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1063 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1064 channel_name="latest"
1065 else
1066 channel_name="nightly"
1067 fi
1068
1069 echo "Building hosted web app for $channel_name channel."
1070 deployment_output="$(
1071 vp dlx vercel@53.1.1 deploy \
1072 --archive=tgz \
1073 --prod \
1074 --skip-domain \
1075 --yes \
1076 --token "$VERCEL_TOKEN" \
1077 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}" \
1078 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
1079 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
1080 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
1081 --build-env "T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=${T3CODE_CLERK_CLI_OAUTH_CLIENT_ID:-}" \
1082 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
1083 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
1084 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
1085 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
1086 --build-env "VITE_HOSTED_APP_URL=$router_url" \
1087 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
1088 )"
1089 printf '%s\n' "$deployment_output"
1090 # Vercel can print lockfile warnings to stdout before the deployment URL.
1091 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1092 if [[ "$deployment_url" == *$'\n'* ]]; then
1093 echo "Vercel returned multiple deployment URLs." >&2
1094 exit 1
1095 fi
1096 echo "Staged $deployment_url."
1097 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1098
1099 deploy_web:
1100 name: Deploy hosted web app
1101 needs: [preflight, build_web, release, publish_cli]
1102 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' }}
1103 runs-on: blacksmith-2vcpu-ubuntu-2404
1104 timeout-minutes: 10
1105 env:
1106 DEPLOYMENT_URL: ${{ needs.build_web.outputs.deployment_url }}
1107 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1108 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1109 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1110 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1111 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
1112 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
1113 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1114 steps:
1115 - name: Checkout
1116 uses: actions/checkout@v6
1117 with:
1118 ref: ${{ needs.preflight.outputs.ref }}
1119 sparse-checkout: |
1120 /*
1121 !/.repos/
1122 sparse-checkout-cone-mode: false
1123
1124 - name: Setup Vite+
1125 uses: ./.github/actions/setup-ci-deps
1126 with:
1127 install: false
1128
1129 - name: Alias channel
1130 shell: bash
1131 run: |
1132 set -euo pipefail
1133
1134 if [[ -z "$DEPLOYMENT_URL" ]]; then
1135 echo "Build hosted web app did not report a deployment URL." >&2
1136 exit 1
1137 fi
1138
1139 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1140 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
1141 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
1142 router_domain="${router_url#http://}"
1143 router_domain="${router_domain#https://}"
1144 router_domain="${router_domain%%/*}"
1145
1146 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1147 channel_domain="$latest_domain"
1148 channel_name="latest"
1149 else
1150 channel_domain="$nightly_domain"
1151 channel_name="nightly"
1152 fi
1153
1154 vercel_scope_args=(--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}")
1155
1156 echo "Aliasing $DEPLOYMENT_URL to $channel_domain."
1157 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$channel_domain" \
1158 --token "$VERCEL_TOKEN" \
1159 "${vercel_scope_args[@]}"
1160
1161 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
1162 echo "Aliasing $DEPLOYMENT_URL to router domain $router_domain."
1163 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$router_domain" \
1164 --token "$VERCEL_TOKEN" \
1165 "${vercel_scope_args[@]}"
1166 fi
1167
1168 # Same split as the web app: build a production deployment early, then
1169 # promote it to t3.codes once the release it links to exists. As above, the
1170 # project's own *.vercel.app hostname moves at build time.
1171 build_marketing:
1172 name: Build marketing site
1173 needs: [preflight]
1174 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1175 runs-on: blacksmith-8vcpu-ubuntu-2404
1176 timeout-minutes: 10
1177 outputs:
1178 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1179 project_id: ${{ steps.deploy.outputs.project_id }}
1180 env:
1181 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1182 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1183 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1184 steps:
1185 - name: Checkout
1186 uses: actions/checkout@v6
1187 with:
1188 ref: ${{ needs.preflight.outputs.ref }}
1189 sparse-checkout: |
1190 /*
1191 !/.repos/
1192 sparse-checkout-cone-mode: false
1193
1194 - name: Setup dependencies
1195 uses: ./.github/actions/setup-ci-deps
1196 with:
1197 install-args: --filter=@t3tools/marketing...
1198
1199 - id: deploy
1200 name: Build staged deployment
1201 shell: bash
1202 run: |
1203 set -euo pipefail
1204
1205 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" ]]; then
1206 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID." >&2
1207 exit 1
1208 fi
1209
1210 VERCEL_PROJECT_ID="$(
1211 curl --fail --silent --show-error \
1212 --header "Authorization: Bearer $VERCEL_TOKEN" \
1213 "https://api.vercel.com/v9/projects/t3code-marketing?teamId=$VERCEL_ORG_ID" \
1214 | jq --exit-status --raw-output '.id'
1215 )"
1216 export VERCEL_PROJECT_ID
1217
1218 deployment_output="$(
1219 vp dlx vercel@53.1.1 deploy \
1220 --archive=tgz \
1221 --prod \
1222 --skip-domain \
1223 --yes \
1224 --token "$VERCEL_TOKEN" \
1225 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1226 )"
1227 printf '%s\n' "$deployment_output"
1228 # Vercel can print lockfile warnings to stdout before the deployment URL.
1229 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1230 if [[ "$deployment_url" == *$'\n'* ]]; then
1231 echo "Vercel returned multiple deployment URLs." >&2
1232 exit 1
1233 fi
1234 echo "Staged $deployment_url."
1235 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1236 echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"
1237
1238 deploy_marketing:
1239 name: Deploy marketing site
1240 needs: [preflight, build_marketing, release]
1241 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_marketing.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1242 runs-on: blacksmith-2vcpu-ubuntu-2404
1243 timeout-minutes: 10
1244 env:
1245 DEPLOYMENT_URL: ${{ needs.build_marketing.outputs.deployment_url }}
1246 VERCEL_PROJECT_ID: ${{ needs.build_marketing.outputs.project_id }}
1247 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1248 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1249 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1250 steps:
1251 - name: Checkout
1252 uses: actions/checkout@v6
1253 with:
1254 ref: ${{ needs.preflight.outputs.ref }}
1255 sparse-checkout: |
1256 /*
1257 !/.repos/
1258 sparse-checkout-cone-mode: false
1259
1260 - name: Setup Vite+
1261 uses: ./.github/actions/setup-ci-deps
1262 with:
1263 install: false
1264
1265 - name: Promote marketing site
1266 shell: bash
1267 run: |
1268 set -euo pipefail
1269
1270 if [[ -z "$DEPLOYMENT_URL" ]]; then
1271 echo "Build marketing site did not report a deployment URL." >&2
1272 exit 1
1273 fi
1274
1275 echo "Promoting $DEPLOYMENT_URL."
1276 vp dlx vercel@53.1.1 promote "$DEPLOYMENT_URL" \
1277 --yes \
1278 --token "$VERCEL_TOKEN" \
1279 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1280
1281 finalize:
1282 name: Finalize release
1283 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
1284 needs: [preflight, release]
1285 runs-on: blacksmith-8vcpu-ubuntu-2404
1286 timeout-minutes: 10
1287 steps:
1288 - id: app_token
1289 name: Mint release app token
1290 uses: actions/create-github-app-token@v2
1291 with:
1292 app-id: ${{ secrets.RELEASE_APP_ID }}
1293 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
1294 owner: ${{ github.repository_owner }}
1295
1296 - name: Checkout
1297 uses: actions/checkout@v6
1298 with:
1299 ref: main
1300 fetch-depth: 0
1301 token: ${{ steps.app_token.outputs.token }}
1302 persist-credentials: true
1303 sparse-checkout: |
1304 /*
1305 !/.repos/
1306 sparse-checkout-cone-mode: false
1307
1308 - id: app_bot
1309 name: Resolve GitHub App bot identity
1310 env:
1311 GH_TOKEN: ${{ steps.app_token.outputs.token }}
1312 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
1313 run: |
1314 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
1315 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
1316 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
1317
1318 - name: Setup dependencies
1319 uses: ./.github/actions/setup-ci-deps
1320 with:
1321 install-args: --filter=@t3tools/scripts... --filter=@t3tools/oxlint-plugin-t3code...
1322
1323 - id: update_versions
1324 name: Update version strings
1325 env:
1326 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
1327 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
1328
1329 - name: Format package.json files
1330 if: steps.update_versions.outputs.changed == 'true'
1331 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
1332
1333 - name: Refresh lockfile
1334 if: steps.update_versions.outputs.changed == 'true'
1335 run: vp install --lockfile-only --ignore-scripts
1336
1337 - name: Commit and push version bump
1338 if: steps.update_versions.outputs.changed == 'true'
1339 shell: bash
1340 env:
1341 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1342 run: |
1343 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
1344 echo "No version changes to commit."
1345 exit 0
1346 fi
1347
1348 git config user.name "${{ steps.app_bot.outputs.name }}"
1349 git config user.email "${{ steps.app_bot.outputs.email }}"
1350
1351 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
1352 git commit -m "chore(release): prepare $RELEASE_TAG"
1353 git push origin HEAD:main
1354
1355 announce_discord:
1356 name: Announce release on Discord
1357 if: |
1358 always() && !cancelled() &&
1359 needs.preflight.result == 'success' &&
1360 needs.preflight.outputs.release_channel != 'preview' &&
1361 needs.relay_public_config.result == 'success' &&
1362 needs.release.result == 'success' &&
1363 needs.deploy_web.result == 'success' &&
1364 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
1365 needs: [preflight, relay_public_config, release, deploy_web, finalize]
1366 runs-on: blacksmith-8vcpu-ubuntu-2404
1367 timeout-minutes: 10
1368 steps:
1369 - name: Checkout
1370 uses: actions/checkout@v6
1371 with:
1372 ref: ${{ needs.preflight.outputs.ref }}
1373 sparse-checkout: |
1374 /*
1375 !/.repos/
1376 sparse-checkout-cone-mode: false
1377
1378 - name: Setup dependencies
1379 uses: ./.github/actions/setup-ci-deps
1380 with:
1381 install-args: --filter=@t3tools/scripts...
1382
1383 - name: Read published release notes
1384 if: needs.preflight.outputs.is_prerelease == 'true'
1385 continue-on-error: true
1386 env:
1387 GH_TOKEN: ${{ github.token }}
1388 GH_REPO: ${{ github.repository }}
1389 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1390 RELEASE_CHANNEL: ${{ needs.preflight.outputs.release_channel }}
1391 run: |
1392 if [ "$RELEASE_CHANNEL" = 'nightly' ]; then
1393 if ! gh release view "$RELEASE_TAG" --json body --jq '.body // ""' > "$RUNNER_TEMP/discord-release-notes.md"; then
1394 : > "$RUNNER_TEMP/discord-release-notes.md"
1395 echo '::warning::Could not read published release notes; announcing without a changelog.'
1396 fi
1397 else
1398 : > "$RUNNER_TEMP/discord-release-notes.md"
1399 fi
1400
1401 - name: Announce prerelease on Discord
1402 if: needs.preflight.outputs.is_prerelease == 'true'
1403 continue-on-error: true
1404 env:
1405 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
1406 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1407 run: |
1408 node scripts/notify-discord-release.ts prerelease \
1409 --role-id "$DISCORD_MENTION_ROLE_ID" \
1410 --release-name "${{ needs.preflight.outputs.release_name }}" \
1411 --release-version "${{ needs.preflight.outputs.version }}" \
1412 --tag "${{ needs.preflight.outputs.tag }}" \
1413 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}" \
1414 --release-notes-file "$RUNNER_TEMP/discord-release-notes.md"
1415
1416 - name: Announce latest release on Discord
1417 if: needs.preflight.outputs.make_latest == 'true'
1418 continue-on-error: true
1419 env:
1420 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
1421 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1422 run: |
1423 node scripts/notify-discord-release.ts latest \
1424 --role-id "$DISCORD_MENTION_ROLE_ID" \
1425 --release-name "${{ needs.preflight.outputs.release_name }}" \
1426 --release-version "${{ needs.preflight.outputs.version }}" \
1427 --tag "${{ needs.preflight.outputs.tag }}" \
1428 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"