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