|
6 | 6 | - "v*" |
7 | 7 |
|
8 | 8 | permissions: |
9 | | - contents: write # Need write access to create releases |
10 | | - id-token: write |
| 9 | + contents: read |
11 | 10 |
|
12 | 11 | jobs: |
13 | 12 | publish: |
14 | 13 | name: Publish to NPM |
15 | 14 | runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 20 |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + id-token: write |
16 | 19 | steps: |
17 | | - - name: Checkout |
18 | | - uses: actions/checkout@v4 |
| 20 | + - name: Checkout tagged candidate |
| 21 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 22 | + with: |
| 23 | + ref: ${{ github.sha }} |
19 | 24 |
|
20 | 25 | - name: Setup pnpm |
21 | | - uses: pnpm/action-setup@v4 |
| 26 | + uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 |
22 | 27 |
|
23 | 28 | - name: Setup Node.js |
24 | | - uses: actions/setup-node@v4 |
| 29 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
25 | 30 | with: |
26 | 31 | node-version: 22 |
27 | 32 | cache: pnpm |
28 | 33 | registry-url: "https://registry.npmjs.org" |
29 | 34 |
|
30 | 35 | - name: Install dependencies |
31 | | - run: pnpm install |
| 36 | + run: pnpm install --frozen-lockfile |
32 | 37 |
|
33 | | - - name: Run checks |
34 | | - run: | |
35 | | - pnpm run check |
36 | | - pnpm run type-check |
| 38 | + - name: Validate tag, checks and exact package archive |
| 39 | + run: pnpm run release:prepare |
| 40 | + env: |
| 41 | + RELEASE_TAG: ${{ github.ref_name }} |
37 | 42 |
|
38 | | - - name: Build |
39 | | - run: pnpm run build |
| 43 | + - name: Setup minimum consumer Node |
| 44 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 45 | + with: |
| 46 | + node-version: 20.0.0 |
| 47 | + |
| 48 | + - name: Verify installed archive on the minimum consumer runtime |
| 49 | + run: node .release/consumer/check.mjs |
40 | 50 |
|
41 | | - - name: Publish |
42 | | - run: pnpm publish --no-git-checks |
| 51 | + - name: Restore publishing Node |
| 52 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 53 | + with: |
| 54 | + node-version: 22 |
| 55 | + registry-url: "https://registry.npmjs.org" |
| 56 | + |
| 57 | + # release:prepare already ran tests/build and validated this archive. |
| 58 | + # Suppress lifecycle rebuilds so publication uses the same bytes. |
| 59 | + - name: Publish validated archive |
| 60 | + run: | |
| 61 | + sha256sum --check .release/package.sha256 |
| 62 | + pnpm publish .release/package.tgz --ignore-scripts --no-git-checks |
43 | 63 | env: |
44 | 64 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
45 | 65 |
|
46 | 66 | create-release: |
47 | 67 | name: Create GitHub Release |
48 | 68 | runs-on: ubuntu-latest |
49 | | - needs: publish # Wait for npm publish to succeed |
| 69 | + needs: publish |
| 70 | + permissions: |
| 71 | + contents: write |
50 | 72 | steps: |
51 | | - - name: Checkout |
52 | | - uses: actions/checkout@v4 |
| 73 | + - name: Checkout tagged candidate |
| 74 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 75 | + with: |
| 76 | + ref: ${{ github.sha }} |
53 | 77 |
|
54 | 78 | - name: Create Release |
55 | | - uses: softprops/action-gh-release@v2 |
| 79 | + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 |
56 | 80 | with: |
57 | 81 | tag_name: ${{ github.ref_name }} |
58 | 82 | name: Release ${{ github.ref_name }} |
|
0 commit comments