Skip to content

Publish to npm

Publish to npm #9

Workflow file for this run

name: Publish to npm
on:
push:
tags: ["*"]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- name: Verify tag matches package.json version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION="$(node -p "require('./package.json').version")"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "Tag $GITHUB_REF_NAME does not match package.json version $PKG_VERSION" >&2
exit 1
fi
- name: Upgrade npm for Trusted Publishing
run: npm install -g npm@latest
- run: npm ci
- run: npm run build
- run: npm publish --access public
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --generate-notes