|
| 1 | +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created |
| 2 | +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages |
| 3 | +name: Node.js Package |
| 4 | + |
| 5 | +on: |
| 6 | + release: |
| 7 | + types: [created] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - uses: actions/setup-node@v4 |
| 17 | + with: |
| 18 | + node-version: 20 |
| 19 | + - run: npm ci |
| 20 | + working-directory: './frontend' |
| 21 | + - run: npm run test |
| 22 | + working-directory: './frontend' |
| 23 | + |
| 24 | + publish-gpr: |
| 25 | + needs: build |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + packages: write |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: '20.x' |
| 35 | + registry-url: https://npm.pkg.github.com/ |
| 36 | + scope: '@conorheffron' |
| 37 | + - run: npm ci |
| 38 | + working-directory: './frontend' |
| 39 | + - run: npm set "//npm.pkg.github.com/:_authToken=$NPM_TOKEN" |
| 40 | + working-directory: './frontend' |
| 41 | + env: |
| 42 | + NPM_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 43 | + - run: echo registry=https://npm.pkg.github.com/conorheffron >> .npmrc |
| 44 | + working-directory: './frontend' |
| 45 | + - run: npm publish |
| 46 | + working-directory: './frontend' |
| 47 | + env: |
| 48 | + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 49 | + |
| 50 | + publish-npm: |
| 51 | + needs: build |
| 52 | + runs-on: ubuntu-latest |
| 53 | + permissions: |
| 54 | + contents: read |
| 55 | + packages: write |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version: '20.x' |
| 61 | + registry-url: https://registry.npmjs.org/ |
| 62 | + - run: npm ci |
| 63 | + working-directory: './frontend' |
| 64 | + - run: npm set "//registry.npmjs.org/conorheffron/:_authToken=$NPM_TOKEN" |
| 65 | + working-directory: './frontend' |
| 66 | + env: |
| 67 | + NPM_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} |
| 68 | + - run: npm publish --access public |
| 69 | + working-directory: './frontend' |
| 70 | + env: |
| 71 | + NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} |
0 commit comments