From 6ad782c70e495e98d0337460a08be9017105fd00 Mon Sep 17 00:00:00 2001 From: Onni Hakala Date: Tue, 30 Jan 2024 12:00:41 +0100 Subject: [PATCH] Add Github Action workflow to publish releases automatically to NPM registry --- .github/workflows/publish-to-npmjs.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/publish-to-npmjs.yml diff --git a/.github/workflows/publish-to-npmjs.yml b/.github/workflows/publish-to-npmjs.yml new file mode 100644 index 000000000..044432b47 --- /dev/null +++ b/.github/workflows/publish-to-npmjs.yml @@ -0,0 +1,22 @@ +# Publishes a package to npmjs.com after each release (basically git tags) +# Source: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry +name: Publish Package to npmjs +on: + release: + types: [published] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: yarn + registry-url: 'https://registry.npmjs.org' + - run: yarn install --frozen-lockfile + - run: yarn test + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}