diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 077d200..fa1b084 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -6,15 +6,12 @@ name: Node.js CI on: [push, pull_request] jobs: - build: - + test: runs-on: ubuntu-latest - strategy: matrix: node-version: [lts/*, latest] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} @@ -25,3 +22,24 @@ jobs: - run: npm ci - run: npm run build --if-present - run: npm test + publish: + name: Publish + needs: [test] + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + registry-url: https://registry.npmjs.org/ + - name: Install dependencies + run: npm ci + - name: Publish package to NPM + run: npm publish --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}