|
1 | | -name: Publish to npm |
| 1 | +name: Publish to npm + GitHub Packages |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
8 | 8 | permissions: |
9 | 9 | contents: write # needed for creating GitHub Releases |
10 | 10 | id-token: write # needed for npm provenance |
| 11 | + packages: write # needed for GitHub Packages |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | test: |
|
24 | 25 | - name: Run test suite |
25 | 26 | run: node test/run.js |
26 | 27 |
|
27 | | - publish: |
| 28 | + publish-npm: |
28 | 29 | name: Publish to npm |
29 | 30 | needs: test |
30 | 31 | runs-on: ubuntu-latest |
|
52 | 53 | env: |
53 | 54 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
54 | 55 |
|
| 56 | + publish-github: |
| 57 | + name: Publish to GitHub Packages |
| 58 | + needs: test |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Setup Node.js |
| 64 | + uses: actions/setup-node@v4 |
| 65 | + with: |
| 66 | + node-version: '20' |
| 67 | + registry-url: 'https://npm.pkg.github.com' |
| 68 | + scope: '@manojmallick' |
| 69 | + |
| 70 | + - name: Publish to GitHub Packages |
| 71 | + run: | |
| 72 | + # GitHub Packages requires a scoped name — publish as @manojmallick/sigmap |
| 73 | + # without altering the canonical package.json (which stays as "sigmap" for npmjs.com) |
| 74 | + node -e " |
| 75 | + const fs = require('fs'); |
| 76 | + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
| 77 | + pkg.name = '@manojmallick/sigmap'; |
| 78 | + pkg.publishConfig = { registry: 'https://npm.pkg.github.com' }; |
| 79 | + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); |
| 80 | + " |
| 81 | + npm publish --access public |
| 82 | + env: |
| 83 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + |
| 85 | + release: |
| 86 | + name: Create GitHub Release |
| 87 | + needs: [publish-npm, publish-github] |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v4 |
| 91 | + |
55 | 92 | - name: Create GitHub Release |
56 | 93 | uses: softprops/action-gh-release@v2 |
57 | 94 | with: |
|
0 commit comments