11name : npm-publish
22
33on :
4- release :
5- types : [published]
64 workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : >-
8+ Release tag to publish, for example v1.0.0. Leave empty to run
9+ validation only (dry run).
10+ type : string
711
812permissions :
913 contents : read
1014
1115concurrency :
12- # tag_name grouping - queues actual releases for the same tag
13- # run_id - fallback value required for group as tag_name might not always be present (manual triggers)
14- group : npm-publish-${{ github.event.release.tag_name || github.run_id }}
16+ # tag grouping - queues repeat publishes of the same release
17+ # run_id - fallback for validation-only runs, which have no tag
18+ group : npm-publish-${{ inputs.tag || github.run_id }}
1519 cancel-in-progress : false
1620
1721jobs :
@@ -21,29 +25,28 @@ jobs:
2125 steps :
2226 - uses : actions/checkout@v7
2327 with :
24- ref : ${{ github.event.release.tag_name || github.ref }}
28+ ref : ${{ inputs.tag || github.ref }}
2529 persist-credentials : false
2630
2731 - uses : actions/setup-node@v7
2832 with :
29- node-version : 22 .x
33+ node-version : 26 .x
3034
3135 - name : verify release version
32- if : github.event_name == 'release '
36+ if : inputs.tag != ' '
3337 run : |
3438 pkg_name=$(jq -r .name package.json)
3539 pkg_version=$(jq -r .version package.json)
36- tag_version="${GITHUB_EVENT_RELEASE_TAG_NAME#v}"
37- if [ "$pkg_version" != "$tag_version" ]; then
38- echo "package.json version ($pkg_version) does not match release tag ($tag_version)"
40+ if [ "v${pkg_version}" != "$RELEASE_TAG" ]; then
41+ echo "package.json version ($pkg_version) does not match release tag ($RELEASE_TAG)"
3942 exit 1
4043 fi
4144 if npm view "${pkg_name}@${pkg_version}" version >/dev/null 2>&1; then
4245 echo "${pkg_name}@${pkg_version} is already published"
4346 exit 1
4447 fi
4548 env :
46- GITHUB_EVENT_RELEASE_TAG_NAME : ${{ github.event.release.tag_name }}
49+ RELEASE_TAG : ${{ inputs.tag }}
4750
4851 - name : validate publish package contents
4952 run : |
5558 publish :
5659 name : publish
5760 needs : validate
58- if : github.event_name == 'release '
61+ if : inputs.tag != ' '
5962 runs-on : ubuntu-latest
6063 environment : Publish
6164 permissions :
@@ -64,12 +67,12 @@ jobs:
6467 steps :
6568 - uses : actions/checkout@v7
6669 with :
67- ref : ${{ github.event.release.tag_name }}
70+ ref : ${{ inputs.tag }}
6871 persist-credentials : false
6972
7073 - uses : actions/setup-node@v7
7174 with :
72- node-version : 22 .x
75+ node-version : 26 .x
7376 registry-url : https://registry.npmjs.org
7477
7578 - name : publish to npm
0 commit comments