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