Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish to npm

on:
push:
tags: ['v*']

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: '22'
cache: npm
- run: npm ci
- run: npm run lint
- run: npm test

publish:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: '22'
cache: npm
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- name: Verify tag matches package.json version
env:
TAG_REF: ${{ github.ref_name }}
run: |
TAG_VERSION="${TAG_REF#v}"
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "Tag $TAG_VERSION does not match package.json version $PKG_VERSION"
exit 1
fi
- run: npm publish --provenance --access public
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
TAG_REF: ${{ github.ref_name }}
run: gh release create "$TAG_REF" --generate-notes