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