11name : Release to npm
22
3- # Manual only. There is no push/tag trigger on purpose: publishing is
4- # irreversible (npm forbids re-using a version number, and unpublishing is
5- # restricted), so it should never happen as a side effect of a commit.
3+ # Fires when release-please publishes a GitHub Release — that only happens when a
4+ # release pull request is merged, which is itself a deliberate act with the version
5+ # and changelog visible for review. So merging the release PR is the single action
6+ # that ships a version.
7+ #
8+ # Still dispatchable by hand, defaulting to a dry run, for re-publishing after a
9+ # failure or validating the tarball without shipping.
610on :
11+ release :
12+ types : [published]
713 workflow_dispatch :
814 inputs :
915 dry_run :
6369 fi
6470
6571 - name : Pack (dry run)
66- if : inputs.dry_run
72+ if : ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
6773 run : npm publish --dry-run
6874
6975 # No NODE_AUTH_TOKEN. Publishing uses npm trusted publishing (OIDC): npm
@@ -74,13 +80,12 @@ jobs:
7480 #
7581 # Provenance is automatic under OIDC for a public package from a public repo,
7682 # so --provenance is not passed explicitly.
83+ # On a release event inputs.dry_run is undefined, so this must not rely on
84+ # negating it — an undefined input would otherwise read as "not a dry run"
85+ # by luck rather than intent.
7786 - name : Publish
78- if : ${{ !inputs.dry_run }}
87+ if : ${{ github.event_name == 'release' || !inputs.dry_run }}
7988 run : npm publish --access public
8089
81- - name : Tag the released commit
82- if : ${{ !inputs.dry_run }}
83- run : |
84- VERSION=$(node -p "require('./package.json').version")
85- git tag "v$VERSION"
86- git push origin "v$VERSION"
90+ # No tagging step: release-please already created the tag and the GitHub
91+ # Release that triggered this run.
0 commit comments