Skip to content

Commit 510ea0b

Browse files
[AI] Add release-triggered npm publishing workflow
1 parent c75267f commit 510ea0b

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish npm Package
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
registry-url: https://registry.npmjs.org
24+
25+
- name: Validate release tag matches package version
26+
run: |
27+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
28+
TAG_NAME="${{ github.event.release.tag_name }}"
29+
TAG_VERSION="${TAG_NAME#v}"
30+
31+
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
32+
echo "Release tag ($TAG_NAME) does not match package version ($PACKAGE_VERSION)."
33+
exit 1
34+
fi
35+
36+
- name: Install dependencies
37+
run: npm install
38+
39+
- name: Build
40+
run: npm run build
41+
42+
- name: Publish prerelease to npm (next)
43+
if: github.event.release.prerelease == true
44+
run: npm publish --tag next --provenance
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
- name: Publish release to npm (latest)
49+
if: github.event.release.prerelease == false
50+
run: npm publish --provenance
51+
env:
52+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,8 @@ When asked to create commits in this repository:
139139
- Context: `--yaml` overlapped with `--base` by auto-detecting file paths, which created ambiguous query source behavior.
140140
- Decision: Restrict `--yaml`/`yaml` to inline YAML text and reject path-like input with guidance to use `--base`/`basePath`.
141141
- Consequence: CLI and library query-source semantics are clearer and avoid accidental mode switching based on filesystem state.
142+
143+
- 2026-02-18 - Release-driven npm publishing
144+
- Context: Package publication should happen automatically when a GitHub release is published.
145+
- Decision: Add a `publish-npm` GitHub Actions workflow triggered by `release.published`, using `NPM_TOKEN` and validating release tag/version alignment before `npm publish`.
146+
- Consequence: Publishing is automated and guarded against accidental version/tag mismatches.

0 commit comments

Comments
 (0)