|
3 | 3 |
|
4 | 4 | name: CI |
5 | 5 |
|
6 | | -permissions: |
7 | | - contents: write |
8 | | - pull-requests: write |
9 | 6 | on: |
10 | 7 | push: |
11 | 8 | branches: |
|
22 | 19 |
|
23 | 20 | strategy: |
24 | 21 | matrix: |
25 | | - node-version: |
26 | | - - 20.x |
27 | | - - 22.x |
| 22 | + node-version: [20, 22] |
28 | 23 |
|
29 | 24 | steps: |
30 | 25 | - uses: actions/checkout@v6 |
@@ -61,39 +56,47 @@ jobs: |
61 | 56 | npm-publish-build: |
62 | 57 | needs: build |
63 | 58 | runs-on: ubuntu-latest |
| 59 | + permissions: |
| 60 | + id-token: write |
| 61 | + contents: read |
64 | 62 | steps: |
65 | 63 | - uses: actions/download-artifact@v7 |
66 | 64 | with: |
67 | 65 | name: build |
68 | 66 | - uses: actions/setup-node@v6 |
69 | 67 | with: |
70 | | - node-version: 20.x |
| 68 | + node-version: 20 |
| 69 | + registry-url: 'https://registry.npmjs.org' |
| 70 | + - name: Update npm to latest (required for OIDC) |
| 71 | + run: npm install -g npm@latest |
71 | 72 | - uses: rlespinasse/github-slug-action@v3.x |
72 | 73 | - name: Append commit hash to package version |
73 | 74 | run: 'sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json' |
74 | 75 | - name: Disable pre- and post-publish actions |
75 | 76 | run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json' |
76 | | - - uses: JS-DevTools/npm-publish@v4.1.4 |
| 77 | + - name: Publish to npm |
77 | 78 | if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' |
78 | | - with: |
79 | | - token: ${{ secrets.NPM_TOKEN }} |
80 | | - tag: ${{ env.GITHUB_REF_SLUG }} |
| 79 | + run: npm publish --tag ${{ env.GITHUB_REF_SLUG }} |
81 | 80 |
|
82 | 81 | npm-publish-latest: |
83 | 82 | needs: [build, npm-publish-build] |
84 | 83 | runs-on: ubuntu-latest |
85 | 84 | if: github.ref == 'refs/heads/main' |
| 85 | + permissions: |
| 86 | + id-token: write # Required for OIDC |
| 87 | + contents: read |
86 | 88 | steps: |
87 | 89 | - uses: actions/download-artifact@v7 |
88 | 90 | with: |
89 | 91 | name: build |
90 | 92 | - uses: actions/setup-node@v6 |
91 | 93 | with: |
92 | | - node-version: 20.x |
| 94 | + node-version: 20 |
| 95 | + registry-url: 'https://registry.npmjs.org' |
| 96 | + - name: Update npm to latest (required for OIDC) |
| 97 | + run: npm install -g npm@latest |
93 | 98 | - name: Disable pre- and post-publish actions |
94 | 99 | run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json' |
95 | | - - uses: JS-DevTools/npm-publish@v4.1.4 |
| 100 | + - name: Publish to npm |
96 | 101 | if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' |
97 | | - with: |
98 | | - token: ${{ secrets.NPM_TOKEN }} |
99 | | - tag: latest |
| 102 | + run: npm publish --tag latest |
0 commit comments