v0.0.1 #1
Workflow file for this run
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: Publish npm package | |
| on: | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| publish: | |
| if: github.event.release.prerelease == false | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Ensure tag matches package version | |
| run: | | |
| VERSION="$(node -p "JSON.parse(require('node:fs').readFileSync('package.json', 'utf8')).version")" | |
| TAG="${GITHUB_REF_NAME#v}" | |
| if [ "$TAG" != "$VERSION" ]; then | |
| echo "Release tag must be v$VERSION, got ${GITHUB_REF_NAME}." | |
| exit 1 | |
| fi | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Verify publish contents | |
| run: npm pack --dry-run | |
| - name: Publish to npm | |
| run: npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |