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