TypeScript
ci(release): npm publish no longer checks out and installs the workspace (#31936)
Theo Brownecb8e0ded774d
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex a74ef08c5ae..55ebb88b367 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -517,6 +517,8 @@ jobs:if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}runs-on: blacksmith-32vcpu-ubuntu-2404timeout-minutes: 30+ outputs:+ npm_launcher_artifact_id: ${{ steps.npm_launcher.outputs.artifact-id }}env:T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}@@ -604,6 +606,22 @@ jobs:if-no-files-found: errorretention-days: 1+ # publish_cli publishes this exact tarball, so the trusted publisher+ # needs no workspace checkout or install. It is version-matched here.+ - name: Build the npm launcher+ run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages++ # GitHub allows a failed-jobs rerun for 30 days. publish_cli downloads+ # this upload by its ID, which a publish_cli-only rerun keeps.+ - name: Upload the npm launcher+ id: npm_launcher+ uses: actions/upload-artifact@v7+ with:+ name: npm-launcher+ path: npm-packages/t3.tgz+ if-no-files-found: error+ retention-days: 30+# One job per platform and architecture (see release-desktop.yml), each# gated only on the JS bundle. Windows targets build on Linux and run their# native checks on a Windows runner of their own architecture.@@ -1023,7 +1041,7 @@ jobs:# nothing resolves unless asked for by name.publish_cli:name: Publish CLI to npm- needs: [preflight, release]+ needs: [preflight, build_bundle, release]if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404timeout-minutes: 15@@ -1031,26 +1049,57 @@ jobs:contents: readid-token: writesteps:+ # Only what setup-ci-deps reads to install the project's Node and npm.- name: Checkoutuses: actions/checkout@v6with:ref: ${{ needs.preflight.outputs.ref }}sparse-checkout: |- /*- !/.repos/+ /.github/actions/setup-ci-deps/+ /package.json+ /pnpm-workspace.yamlsparse-checkout-cone-mode: false- - name: Setup dependencies+ - name: Setup Node.jsuses: ./.github/actions/setup-ci-depswith:- install-args: --filter=t3... --filter=@t3tools/scripts...+ install: "false"- - name: Build the npm launcher- run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages+ # Bind to build_bundle's exact upload: a name lookup takes the newest+ # same-name artifact, and an empty ID downloads every artifact in the+ # run. A later same-name upload hides this ID, so the download fails.+ - name: Check the npm launcher artifact ID+ env:+ ARTIFACT_ID: ${{ needs.build_bundle.outputs.npm_launcher_artifact_id }}+ run: |+ if [[ ! "$ARTIFACT_ID" =~ ^[1-9][0-9]*$ ]]; then+ echo "::error::build_bundle gave no valid npm-launcher artifact ID: '$ARTIFACT_ID'." >&2+ exit 1+ fi++ - name: Download the npm launcher+ uses: actions/download-artifact@v8+ with:+ artifact-ids: ${{ needs.build_bundle.outputs.npm_launcher_artifact_id }}+ path: npm-packages+ digest-mismatch: error++ - name: Check the npm launcher version+ env:+ RELEASE_VERSION: ${{ needs.preflight.outputs.version }}+ run: |+ built="$(tar -xzOf npm-packages/t3.tgz package/package.json | jq -r .version)"+ if [[ "$built" != "$RELEASE_VERSION" ]]; then+ echo "::error::npm-launcher holds t3@$built, expected t3@$RELEASE_VERSION." >&2+ exit 1+ fi- name: Publish the npm launcher+ env:+ DIST_TAG: ${{ needs.preflight.outputs.cli_dist_tag }}run: |- if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then+ # The ./ keeps npm from reading the path as a GitHub owner/repo spec.+ if ! npm publish --access public --tag "$DIST_TAG" --provenance ./npm-packages/t3.tgz; thenecho "::error::npm publish failed. Make sure package t3 has a trusted publisher registered for .github/workflows/release.yml (see docs/operations/release.md)." >&2exit 1fidiff --git a/docs/operations/release.md b/docs/operations/release.mdindex d7581d3c08a..be74b2ad298 100644--- a/docs/operations/release.md+++ b/docs/operations/release.md@@ -533,9 +533,11 @@ blockmaps, with a 60 MB maximum for a representative sidecar-to-sidecar update.## 0) npm OIDC trusted publishing setup (CLI)-After the GitHub Release is published, the workflow runs `node scripts/build-npm-launcher.ts`, then-`node apps/server/scripts/cli.ts publish --packages-dir npm-packages`, which runs `npm publish` on-`t3.tgz`. That is the only package published per release.+`build_bundle` builds the version-matched `t3.tgz` with `node scripts/build-npm-launcher.ts` and+uploads it as the `npm-launcher` artifact. After the GitHub Release is published, `publish_cli`+checks out only what it needs to set up the project's Node.js, downloads that exact upload by the+artifact ID `build_bundle` outputs (never by name), checks the tarball version, and runs+`npm publish --provenance` on it. That is the only package published per release.Checklist:@@ -663,7 +665,7 @@ Checklist:- preflight passes- release quality checks pass- `build_bundle` and all platform builds pass- - `publish_cli` publishes the exact release version before the release job+ - `publish_cli` publishes the exact release version after the release job- release job uploads expected files5. Smoke test downloaded artifacts.