@@ -517,6 +517,8 @@ jobs: |
517 | 517 | if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }} |
518 | 518 | runs-on: blacksmith-32vcpu-ubuntu-2404 |
519 | 519 | timeout-minutes: 30 |
| 520 | + outputs: |
| 521 | + npm_launcher_artifact_id: ${{ steps.npm_launcher.outputs.artifact-id }} |
520 | 522 | env: |
521 | 523 | T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }} |
522 | 524 | T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }} |
@@ -604,6 +606,22 @@ jobs: |
604 | 606 | if-no-files-found: error |
605 | 607 | retention-days: 1 |
606 | 608 |
|
| 609 | + # publish_cli publishes this exact tarball, so the trusted publisher |
| 610 | + # needs no workspace checkout or install. It is version-matched here. |
| 611 | + - name: Build the npm launcher |
| 612 | + run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages |
| 613 | + |
| 614 | + # GitHub allows a failed-jobs rerun for 30 days. publish_cli downloads |
| 615 | + # this upload by its ID, which a publish_cli-only rerun keeps. |
| 616 | + - name: Upload the npm launcher |
| 617 | + id: npm_launcher |
| 618 | + uses: actions/upload-artifact@v7 |
| 619 | + with: |
| 620 | + name: npm-launcher |
| 621 | + path: npm-packages/t3.tgz |
| 622 | + if-no-files-found: error |
| 623 | + retention-days: 30 |
| 624 | + |
607 | 625 | # One job per platform and architecture (see release-desktop.yml), each |
608 | 626 | # gated only on the JS bundle. Windows targets build on Linux and run their |
609 | 627 | # native checks on a Windows runner of their own architecture. |
@@ -1023,34 +1041,65 @@ jobs: |
1023 | 1041 | # nothing resolves unless asked for by name. |
1024 | 1042 | publish_cli: |
1025 | 1043 | name: Publish CLI to npm |
1026 | | - needs: [preflight, release] |
| 1044 | + needs: [preflight, build_bundle, release] |
1027 | 1045 | if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }} |
1028 | 1046 | runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404 |
1029 | 1047 | timeout-minutes: 15 |
1030 | 1048 | permissions: |
1031 | 1049 | contents: read |
1032 | 1050 | id-token: write |
1033 | 1051 | steps: |
| 1052 | + # Only what setup-ci-deps reads to install the project's Node and npm. |
1034 | 1053 | - name: Checkout |
1035 | 1054 | uses: actions/checkout@v6 |
1036 | 1055 | with: |
1037 | 1056 | ref: ${{ needs.preflight.outputs.ref }} |
1038 | 1057 | sparse-checkout: | |
1039 | | - /* |
1040 | | - !/.repos/ |
| 1058 | + /.github/actions/setup-ci-deps/ |
| 1059 | + /package.json |
| 1060 | + /pnpm-workspace.yaml |
1041 | 1061 | sparse-checkout-cone-mode: false |
1042 | 1062 |
|
1043 | | - - name: Setup dependencies |
| 1063 | + - name: Setup Node.js |
1044 | 1064 | uses: ./.github/actions/setup-ci-deps |
1045 | 1065 | with: |
1046 | | - install-args: --filter=t3... --filter=@t3tools/scripts... |
| 1066 | + install: "false" |
1047 | 1067 |
|
1048 | | - - name: Build the npm launcher |
1049 | | - run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages |
| 1068 | + # Bind to build_bundle's exact upload: a name lookup takes the newest |
| 1069 | + # same-name artifact, and an empty ID downloads every artifact in the |
| 1070 | + # run. A later same-name upload hides this ID, so the download fails. |
| 1071 | + - name: Check the npm launcher artifact ID |
| 1072 | + env: |
| 1073 | + ARTIFACT_ID: ${{ needs.build_bundle.outputs.npm_launcher_artifact_id }} |
| 1074 | + run: | |
| 1075 | + if [[ ! "$ARTIFACT_ID" =~ ^[1-9][0-9]*$ ]]; then |
| 1076 | + echo "::error::build_bundle gave no valid npm-launcher artifact ID: '$ARTIFACT_ID'." >&2 |
| 1077 | + exit 1 |
| 1078 | + fi |
| 1079 | +
|
| 1080 | + - name: Download the npm launcher |
| 1081 | + uses: actions/download-artifact@v8 |
| 1082 | + with: |
| 1083 | + artifact-ids: ${{ needs.build_bundle.outputs.npm_launcher_artifact_id }} |
| 1084 | + path: npm-packages |
| 1085 | + digest-mismatch: error |
| 1086 | + |
| 1087 | + - name: Check the npm launcher version |
| 1088 | + env: |
| 1089 | + RELEASE_VERSION: ${{ needs.preflight.outputs.version }} |
| 1090 | + run: | |
| 1091 | + built="$(tar -xzOf npm-packages/t3.tgz package/package.json | jq -r .version)" |
| 1092 | + if [[ "$built" != "$RELEASE_VERSION" ]]; then |
| 1093 | + echo "::error::npm-launcher holds t3@$built, expected t3@$RELEASE_VERSION." >&2 |
| 1094 | + exit 1 |
| 1095 | + fi |
1050 | 1096 |
|
1051 | 1097 | - name: Publish the npm launcher |
| 1098 | + env: |
| 1099 | + DIST_TAG: ${{ needs.preflight.outputs.cli_dist_tag }} |
1052 | 1100 | run: | |
1053 | | - if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then |
| 1101 | + # The ./ keeps npm from reading the path as a GitHub owner/repo spec. |
| 1102 | + if ! npm publish --access public --tag "$DIST_TAG" --provenance ./npm-packages/t3.tgz; then |
1054 | 1103 | 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 |
1055 | 1104 | exit 1 |
1056 | 1105 | fi |
|