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 }}