Skip to content

Commit 50525a7

Browse files
[AI] Add manual npm publish dispatch path
1 parent 5097824 commit 50525a7

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
release:
55
types:
66
- published
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: Optional tag to validate against package version (e.g. v0.0.1)
11+
required: false
12+
type: string
713

814
permissions:
915
contents: read
@@ -25,28 +31,41 @@ jobs:
2531
- name: Validate release tag matches package version
2632
run: |
2733
PACKAGE_VERSION=$(node -p "require('./package.json').version")
28-
TAG_NAME="${{ github.event.release.tag_name }}"
34+
35+
if [ "${{ github.event_name }}" = "release" ]; then
36+
TAG_NAME="${{ github.event.release.tag_name }}"
37+
else
38+
TAG_NAME="${{ github.event.inputs.tag }}"
39+
fi
40+
41+
if [ -z "$TAG_NAME" ]; then
42+
echo "No release tag provided; skipping tag/version validation for manual run."
43+
exit 0
44+
fi
45+
2946
TAG_VERSION="${TAG_NAME#v}"
3047
3148
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
3249
echo "Release tag ($TAG_NAME) does not match package version ($PACKAGE_VERSION)."
3350
exit 1
3451
fi
3552
53+
- name: Decide npm dist-tag
54+
id: npm_tag
55+
run: |
56+
if [ "${{ github.event_name }}" = "release" ] && [ "${{ github.event.release.prerelease }}" = "true" ]; then
57+
echo "value=next" >> "$GITHUB_OUTPUT"
58+
else
59+
echo "value=latest" >> "$GITHUB_OUTPUT"
60+
fi
61+
3662
- name: Install dependencies
3763
run: npm install
3864

3965
- name: Build
4066
run: npm run build
4167

42-
- name: Publish prerelease to npm (next)
43-
if: github.event.release.prerelease == true
44-
run: npm publish --tag next --provenance --access public
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 --access public
68+
- name: Publish package to npm
69+
run: npm publish --tag "${{ steps.npm_tag.outputs.value }}" --provenance --access public
5170
env:
5271
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ When asked to create commits in this repository:
142142

143143
- 2026-02-18 - Release-driven npm publishing
144144
- 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`, validating release tag/version alignment, and publishing with `--access public --provenance`.
146-
- Consequence: Publishing is automated, guarded against version/tag mismatches, and works for first-time public package publication with provenance.
145+
- Decision: Add a `publish-npm` GitHub Actions workflow triggered by `release.published` with manual `workflow_dispatch` support, using `NPM_TOKEN`, validating tag/version alignment when a tag is supplied, and publishing with `--access public --provenance`.
146+
- Consequence: Publishing is automated for releases, can be manually retried without creating a new release, and remains guarded against version/tag mismatches.

0 commit comments

Comments
 (0)