Release #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js from .nvmrc | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: npm | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Ensure manual releases run from main or master | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| if [ "${GITHUB_REF_NAME}" != "main" ] && [ "${GITHUB_REF_NAME}" != "master" ]; then | |
| echo "Manual release must run from main or master." | |
| exit 1 | |
| fi | |
| - name: Determine release state | |
| id: release_state | |
| run: node ./scripts/release-state.mjs | |
| - name: Skip publish when npm is already up to date | |
| if: steps.release_state.outputs.should_publish != 'true' | |
| run: echo '${{ fromJSON(steps.release_state.outputs.reason) }}' | |
| - name: Install dependencies | |
| if: steps.release_state.outputs.should_publish == 'true' | |
| run: npm ci | |
| - name: Run quality checks | |
| if: steps.release_state.outputs.should_publish == 'true' | |
| run: npm run check | |
| - name: Run package smoke test | |
| if: steps.release_state.outputs.should_publish == 'true' | |
| run: npm run test:package | |
| - name: Publish to npm | |
| if: steps.release_state.outputs.should_publish == 'true' | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |