From b831cc5be5d661cb34fa1bae40f9dae463ef515a Mon Sep 17 00:00:00 2001 From: mvelimir Date: Thu, 6 Mar 2025 10:40:27 +0100 Subject: [PATCH] Add job for publishing to npm --- .github/workflows/ci.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25d6a12..aff7ae9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,17 +4,15 @@ on: pull_request: push: branches: [ "main" ] - tags: [ "*" ] + release: + types: [created] jobs: build: - runs-on: ubuntu-latest - strategy: matrix: node-version: [18.x, 20.x, 22.x] - steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} @@ -24,3 +22,18 @@ jobs: cache: 'npm' - run: npm ci - run: npm run build --if-present + + publish-npm: + needs: build + runs-on: ubuntu-latest + if: github.event_name == 'release' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}}