diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 000000000..c4eda2f0c --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +name: Build and publish NPM package + +on: + workflow_dispatch: + inputs: + node_version: + default: '19' + description: 'Node version to use' + required: true + type: string + +jobs: + build-package: + environment: release + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3.3.0 + with: + fetch-depth: 0 # npm run prod requires tags, sadly this is the only way to get them. + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node_version }} + - name: Install dependencies + run: npm install + - name: Test with npm + run: npm run test + - name: Build with npm + run: npm run prod + - name: Publish with npm + if: startsWith(github.ref, 'refs/tags') + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}