mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-18 23:37:13 +00:00
ci: add npm OIDC trusted-publish workflow
Triggers on v* tag push or manual dispatch. Builds, tests, then publishes codeburn to npm with provenance attestation. Uses OIDC so no NPM_TOKEN is stored in repo secrets. The npm-publish GitHub Environment gates the publish step behind a required reviewer, so every release needs explicit human approval before it reaches the registry. Tag/package version mismatch fails fast before any build work. Tests run before publish to prevent shipping a broken release.
This commit is contained in:
parent
7a5cb32e4c
commit
d80f68928b
1 changed files with 50 additions and 0 deletions
50
.github/workflows/publish-npm.yml
vendored
Normal file
50
.github/workflows/publish-npm.yml
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
name: Publish to npm
|
||||
|
||||
# Triggers when a semver tag (v*) is pushed. Publishes `codeburn` to the npm
|
||||
# registry using npm OIDC trusted publishing, so no NPM_TOKEN lives in
|
||||
# secrets. The `npm-publish` Environment requires a human approval before
|
||||
# the publish step runs.
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write # Required for npm OIDC provenance
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
environment: npm-publish
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Verify tag matches package.json
|
||||
run: |
|
||||
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
|
||||
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||
if [[ "$TAG_VERSION" != "$PKG_VERSION" ]]; then
|
||||
echo "Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Run tests
|
||||
run: npm test -- --run
|
||||
|
||||
- name: Publish with provenance
|
||||
run: npm publish --provenance --access public
|
||||
Loading…
Add table
Add a link
Reference in a new issue