| 1 | name: Node.js Package |
| 2 | |
| 3 | on: |
| 4 | release: |
| 5 | types: [created] |
| 6 | |
| 7 | jobs: |
| 8 | build: |
| 9 | runs-on: ubuntu-latest |
| 10 | |
| 11 | steps: |
| 12 | - name: Checkout |
| 13 | uses: actions/checkout@v3 |
| 14 | |
| 15 | - name: Setup Node |
| 16 | uses: actions/setup-node@v3 |
| 17 | with: |
| 18 | node-version: '16.x' |
| 19 | |
| 20 | - name: Install |
| 21 | run: npm ci |
| 22 | |
| 23 | - name: Tests & Coverage |
| 24 | run: | |
| 25 | npm run test |
| 26 | npm run coverage |
| 27 | |
| 28 | - name: Lint |
| 29 | run: npm run lint |
| 30 | |
| 31 | - name: Production Build |
| 32 | run: npm run build:prod |
| 33 | |
| 34 | publish-npm: |
| 35 | needs: build |
| 36 | runs-on: ubuntu-latest |
| 37 | |
| 38 | steps: |
| 39 | - name: Checkout |
| 40 | uses: actions/checkout@v3 |
| 41 | |
| 42 | - name: Setup Node |
| 43 | uses: actions/setup-node@v3 |
| 44 | with: |
| 45 | node-version: '16.x' |
| 46 | registry-url: https://registry.npmjs.org/ |
| 47 | |
| 48 | - name: Read package.json version |
| 49 | uses: tyankatsu0105/read-package-version-actions@v1 |
| 50 | id: package-version |
| 51 | |
| 52 | - name: Install |
| 53 | run: npm ci |
| 54 | |
| 55 | - name: Publish Release |
| 56 | if: ${{ contains(steps.package-version.outputs.version, '-') == false }} |
| 57 | run: npm publish |
| 58 | env: |
| 59 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 60 | |
| 61 | - name: Publish Beta |
| 62 | if: ${{ contains(steps.package-version.outputs.version, 'beta') }} |
| 63 | run: npm publish --tag beta |
| 64 | env: |
| 65 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |