Repository navigation
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 package to npmjs registry | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish-npm: | |
| if: ${{ startsWith(github.event.release.tag_name, 'v') && !github.event.release.draft }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.release.tag_name }} | |
| persist-credentials: false | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: 'npm' | |
| - name: Check the release tag matches package.json | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| run: | | |
| PKG_VERSION="v$(node -p "require('./package.json').version")" | |
| if [ "$RELEASE_TAG" != "$PKG_VERSION" ]; then | |
| echo "::error::release tag $RELEASE_TAG does not match package.json version $PKG_VERSION" | |
| exit 1 | |
| fi | |
| - run: npm ci | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Release | |
| env: | |
| NPM_TAG: ${{ github.event.release.prerelease && 'beta' || 'latest' }} | |
| run: npm publish --access public --tag "$NPM_TAG" | |
| publish-github: | |
| if: ${{ startsWith(github.event.release.tag_name, 'v') && !github.event.release.draft }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.release.tag_name }} | |
| persist-credentials: false | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24 | |
| registry-url: https://npm.pkg.github.com/ | |
| cache: 'npm' | |
| - name: Check the release tag matches package.json | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| run: | | |
| PKG_VERSION="v$(node -p "require('./package.json').version")" | |
| if [ "$RELEASE_TAG" != "$PKG_VERSION" ]; then | |
| echo "::error::release tag $RELEASE_TAG does not match package.json version $PKG_VERSION" | |
| exit 1 | |
| fi | |
| - run: npm ci | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Release | |
| run: npm publish --access public --tag "$NPM_TAG" | |
| env: | |
| NPM_TAG: ${{ github.event.release.prerelease && 'beta' || 'latest' }} | |
| NODE_AUTH_TOKEN: ${{ github.token }} |