@@ -3,6 +3,12 @@ name: 'Release'
33on :
44 release :
55 types : [published]
6+ workflow_dispatch :
7+ inputs :
8+ version :
9+ description : ' Version to publish (e.g. 1.2.0 or v1.2.0)'
10+ required : true
11+ type : string
612
713# Least-privilege by default; the publish job opts into id-token below.
814permissions :
@@ -48,16 +54,22 @@ jobs:
4854 - name : Ensure npm supports trusted publishing
4955 # Trusted publishing requires npm >= 11.5.1.
5056 run : npm install -g npm@latest
51- - name : Verify release tag matches package.json version
52- run : |
53- PKG_VERSION="v$(node -p "require('./package.json').version")"
54- TAG="${{ github.event.release.tag_name }}"
55- if [ "$PKG_VERSION" != "$TAG" ]; then
56- echo "::error::Release tag '$TAG' does not match package.json version '$PKG_VERSION'"
57- exit 1
58- fi
5957 - name : Install dependencies
6058 run : npm ci
59+ - name : Set version to publish
60+ # package.json ships a 0.0.0-development placeholder; the real version
61+ # comes from the manual input (workflow_dispatch) or the release tag,
62+ # with any leading "v" stripped (e.g. v1.2.0 -> 1.2.0).
63+ run : |
64+ VERSION="${INPUT_VERSION:-$TAG}"
65+ if [ -z "$VERSION" ]; then
66+ echo "::error::No version provided" && exit 1
67+ fi
68+ npm pkg set version="${VERSION#v}"
69+ echo "Publishing version ${VERSION#v}"
70+ env :
71+ INPUT_VERSION : ${{ github.event.inputs.version }}
72+ TAG : ${{ github.event.release.tag_name }}
6173 - name : Publish to npm
6274 # No NODE_AUTH_TOKEN: auth happens via OIDC, provenance is automatic.
6375 run : npm publish
0 commit comments