Skip to content

Commit 1f481cd

Browse files
committed
ci: add npm publish workflow
Mirrors @perryts/postgres. Triggered on GitHub release publish or manual workflow_dispatch. Verifies tag matches package.json version, builds via tsc, publishes with provenance using npm trusted publishing (OIDC, no NPM_TOKEN needed).
1 parent fc6f5ff commit 1f481cd

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- uses: actions/setup-node@v5
18+
with:
19+
node-version: "24"
20+
registry-url: "https://registry.npmjs.org"
21+
22+
- name: Verify tag matches package.json version
23+
if: github.event_name == 'release'
24+
run: |
25+
PKG_VERSION=$(node -p "require('./package.json').version")
26+
TAG_VERSION="${GITHUB_REF_NAME#v}"
27+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
28+
echo "::error::Release tag ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
29+
exit 1
30+
fi
31+
32+
- run: npm install --no-audit --no-fund
33+
34+
- run: npm run build
35+
36+
- run: npm publish --provenance --access public

0 commit comments

Comments
 (0)