Skip to content

Commit 4e7092e

Browse files
committed
chore(ci): add release.yml — tag-triggered npm publish + GitHub release
Mirrors agentic-sdlc-wizard's release.yml pattern. Triggers on v* tag push (or manual dispatch with the tag arg as fallback). Gates publish behind: - tag is on main (rejects detached/branch-only tags) - tag matches package.json version (rejects mismatches like v0.2.0 against package version 0.2.1) - npm test passes (113/113 must stay green) Adds --access public to npm publish since opencode-sdlc-wizard is unscoped (not @BaseInfinity/...), and --provenance for supply-chain attestation. Requires NPM_TOKEN secret on the repo before the first tag push.
1 parent e419e2a commit 4e7092e

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Existing tag to publish (e.g. v0.2.0) — fallback when push-trigger misfires'
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
id-token: write
16+
17+
jobs:
18+
publish-and-release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ github.event.inputs.tag || github.ref }}
25+
26+
- name: Verify tag is on main branch
27+
run: |
28+
git fetch origin main
29+
git merge-base --is-ancestor HEAD origin/main || {
30+
echo "::error::Tagged commit is not on main branch. Aborting publish."
31+
exit 1
32+
}
33+
34+
- name: Verify tag matches package.json version
35+
env:
36+
INPUT_TAG: ${{ github.event.inputs.tag }}
37+
run: |
38+
if [ -n "$INPUT_TAG" ]; then
39+
TAG="${INPUT_TAG#v}"
40+
else
41+
TAG="${GITHUB_REF#refs/tags/v}"
42+
fi
43+
PKG=$(node -p "require('./package.json').version")
44+
[ "$TAG" = "$PKG" ] || {
45+
echo "::error::Tag v$TAG does not match package.json version $PKG"
46+
exit 1
47+
}
48+
49+
- uses: actions/setup-node@v5
50+
with:
51+
node-version: 22
52+
registry-url: https://registry.npmjs.org
53+
54+
- name: Run tests
55+
run: npm test
56+
57+
- name: Publish to npm
58+
run: npm publish --provenance --access public
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
62+
- name: Create GitHub Release
63+
run: gh release create "$TAG_NAME" --generate-notes
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
TAG_NAME: ${{ github.event.inputs.tag || github.ref_name }}

0 commit comments

Comments
 (0)