From 5bb411895c7c6ba22263905ee3265e9daa8b0bda Mon Sep 17 00:00:00 2001 From: Donal Linehan Date: Tue, 27 Feb 2024 15:33:48 +0000 Subject: [PATCH] Add action to publish to npm --- .github/workflows/publish.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..af52eb7 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,31 @@ +name: npm publish +on: + release: + types: [published] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - id: get-nvmrc + run: echo VERSION=$(cat .nvmrc) >> $GITHUB_OUTPUT + - id: get-tag + run: | + if [[ $GITHUB_REF =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then + echo TAG=latest >> $GITHUB_OUTPUT + else + echo TAG=beta >> $GITHUB_OUTPUT + fi + - uses: actions/setup-node@v3 + with: + registry-url: https://registry.npmjs.org + node-version: ${{ steps.get-nvmrc.outputs.VERSION }} + - run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_KEY }} + - run: npm run test + - run: npm run build + - run: npm version ${{ github.event.release.tag_name }} --no-git-tag-version + - run: npm publish --tag ${{ steps.get-tag.outputs.TAG }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_KEY }}