48 lines
1.2 KiB
YAML
48 lines
1.2 KiB
YAML
name: Publish to npm
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Verify tag is on main
|
|
run: |
|
|
git merge-base --is-ancestor "$GITHUB_SHA" origin/main || {
|
|
echo "Tag $GITHUB_REF_NAME ($GITHUB_SHA) is not on main; refusing to publish."
|
|
exit 1
|
|
}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Verify tag matches package.json version
|
|
run: node -e "const {version}=require('./package.json'); const tag=process.env.GITHUB_REF_NAME.replace(/^v/,''); if(version!==tag){console.error(\`Tag \${tag} does not match package.json version \${version}\`); process.exit(1);}"
|
|
|
|
- name: Upgrade npm
|
|
run: npm install -g npm@11
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Verify
|
|
run: npm run typecheck && npm test
|
|
|
|
- name: Publish
|
|
run: npm publish --provenance --access public
|