Skip to content

fix(js): Make the GitHub release with a GitHub token - #19

Merged
nfebe merged 1 commit into
mainfrom
js-publish-github-token
Sep 20, 2026
Merged

nfebe merged 1 commit into
mainfrom
js-publish-github-token

Conversation

@nfebe

@nfebe nfebe commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

js/publish passed one token to both the registry and the GitHub release. A caller
publishing to npmjs passes an npm token, so the release step fails on it, after the
package has already gone out.

The release now uses the job token. github_token overrides it where a caller needs
another identity. token becomes optional, since a registry that trusts the workflow
needs none.

The registry token and the release token were the same input, so
publishing to a registry whose token is not a GitHub token failed at the
release step, after the package had already gone out.
@sourceant

sourceant Bot commented Sep 20, 2026

Copy link
Copy Markdown

Code Review Summary

✨ This PR fixes js/publish so that the GitHub release is no longer created with the registry token. Previously a single token input served both npm authentication and softprops/action-gh-release, so callers publishing to a registry with a non-GitHub token (e.g. npmjs) had the package published and then the release step fail. The action now uses github.token for the release, with a new optional github_token input as an override, and token becomes optional for registries that trust the workflow. VERSION is bumped to 1.5.0 and the CHANGELOG.md and README.md entries are updated. Review feedback centers on the fact that this is a consumer-visible behaviour change: the release now depends on the calling job granting contents: write, releases made with github.token do not trigger on: release workflows, and the migration path plus permission requirement are not documented.

🚀 Key Improvements

  • js/publish/action.yml decouples the release identity from the registry token: the release uses github.token unless github_token overrides it, so publishing to npmjs no longer fails at the release step after the package has already gone out.
  • token is now optional with a default of '', allowing registries that trust the workflow (OIDC/trusted publishing) to be used without a registry token.
  • README.md documents that token authenticates the registry while the GitHub release uses the job token unless github_token says otherwise.
  • CHANGELOG.md and VERSION are updated for the 1.5.0 release.

📉 Regressions

  • Callers that previously passed a GitHub PAT (or any non-registry identity) as token to create the release now silently get the job token; the token -> github_token migration path is not called out in CHANGELOG.md, where the change is filed only under ### Fixed.
  • The release made with github.token only works when the calling job grants contents: write — a composite action cannot set permissions itself. Callers whose jobs use the default read-only token, or that previously relied on a release-capable PAT, will now fail the Create GitHub Release step with a 403, again after the package has been published. This requirement is not documented next to the new github_token input in README.md.
  • Releases created with github.token do not trigger on: release workflows, which was previously possible with a PAT; this caveat is undocumented in README.md and CHANGELOG.md.

💡 Minor Suggestions

  • This is a consumer-visible behaviour change, not just a fix: callers that previously passed a GitHub PAT (or any non-registry identity) as token to create the release will now silently get the job token, and releases made with github.token do not trigger on: release workflows. Filing it only under ### Fixed hides that from anyone upgrading, and the version stays at a minor bump. Add a ### Changed section documenting both the migration path (token -> github_token) and the GITHUB_TOKEN-does-not-trigger-workflows caveat.
  • Now that the release uses github.token instead of a caller-supplied token, the calling workflow must grant contents: write — with the read-only default token these repos commonly get, softprops/action-gh-release will fail with a 403. That requirement previously came for free with the PAT and is exactly the kind of failure this change is meant to remove, so it needs to be stated next to the new github_token input.
  • The release step now defaults to github.token, which only authorizes a release when the calling job grants contents: write. Callers who previously relied on a release-capable PAT passed through token (with no registry), or whose job uses the default read-only job token, will fail the Create GitHub Release step after the npm package has already been published. The documented contract should state the required permission alongside the new github_token override.
  • The != '' guard is redundant: inputs.github_token is only ever a string, and GitHub Actions || already selects the right-hand operand for the empty string. ${{ inputs.github_token || github.token }} is equivalent and reads as the intended fallback, reducing the chance of a future edit breaking the guard.
  • Making the release with github.token shifts the permission requirement onto the calling job. github.token can only create a release when the job grants contents: write (the repository default is often read-only, and a composite action cannot set permissions itself). Callers that previously relied on a PAT passed as token will now regress with a 403 at the release step. The documentation should call this out next to the new fallback behavior.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

Comment thread CHANGELOG.md

All notable changes to these reusable actions are documented in this file.

## [1.5.0] - 2026-09-20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a consumer-visible behaviour change, not just a fix: callers that previously passed a GitHub PAT (or any non-registry identity) as token to create the release will now silently get the job token, and releases made with github.token do not trigger on: release workflows. Filing it only under ### Fixed hides that from anyone upgrading, and the version stays at a minor bump. Add a ### Changed section documenting both the migration path (token -> github_token) and the GITHUB_TOKEN-does-not-trigger-workflows caveat.

Suggested change
## [1.5.0] - 2026-09-20
## [1.5.0] - 2026-09-20
### Fixed
- `js/publish` made its GitHub release with the registry token, so publishing to a registry
whose token is not a GitHub token failed after the package was already published. The
release now uses the job token, or `github_token` where a caller needs another.
### Changed
- `token` is now optional and is only sent to the registry. Callers that passed a GitHub
token as `token` in order to create the release must pass it as `github_token` instead.
Releases created with the job token do not trigger `on: release` workflows.

Comment thread README.md

Publishing to the public registry instead needs `registry`, `access`, and a
token for it:
token for it. `token` authenticates the registry, and the GitHub release is made

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the release uses github.token instead of a caller-supplied token, the calling workflow must grant contents: write — with the read-only default token these repos commonly get, softprops/action-gh-release will fail with a 403. That requirement previously came for free with the PAT and is exactly the kind of failure this change is meant to remove, so it needs to be stated next to the new github_token input.

Suggested change
token for it. `token` authenticates the registry, and the GitHub release is made
token for it. `token` authenticates the registry, and the GitHub release is made
with the job token unless `github_token` says otherwise. Creating the release with
the job token requires `permissions: contents: write` on the calling job:

Comment thread README.md

Publishing to the public registry instead needs `registry`, `access`, and a
token for it:
token for it. `token` authenticates the registry, and the GitHub release is made

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release step now defaults to github.token, which only authorizes a release when the calling job grants contents: write. Callers who previously relied on a release-capable PAT passed through token (with no registry), or whose job uses the default read-only job token, will fail the Create GitHub Release step after the npm package has already been published. The documented contract should state the required permission alongside the new github_token override.

Suggested change
token for it. `token` authenticates the registry, and the GitHub release is made
+token for it. `token` authenticates the registry. The GitHub release is made with
+the job token, so the calling job needs `permissions: contents: write` unless
+`github_token` supplies another identity:

Comment thread js/publish/action.yml
uses: softprops/action-gh-release@v2
with:
token: ${{ inputs.token }}
token: ${{ inputs.github_token != '' && inputs.github_token || github.token }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The != '' guard is redundant: inputs.github_token is only ever a string, and GitHub Actions || already selects the right-hand operand for the empty string. ${{ inputs.github_token || github.token }} is equivalent and reads as the intended fallback, reducing the chance of a future edit breaking the guard.

Suggested change
token: ${{ inputs.github_token != '' && inputs.github_token || github.token }}
+ token: ${{ inputs.github_token || github.token }}

Comment thread README.md

Publishing to the public registry instead needs `registry`, `access`, and a
token for it:
token for it. `token` authenticates the registry, and the GitHub release is made

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the release with github.token shifts the permission requirement onto the calling job. github.token can only create a release when the job grants contents: write (the repository default is often read-only, and a composite action cannot set permissions itself). Callers that previously relied on a PAT passed as token will now regress with a 403 at the release step. The documentation should call this out next to the new fallback behavior.

Suggested change
token for it. `token` authenticates the registry, and the GitHub release is made
+token for it. `token` authenticates the registry, and the GitHub release is made
+with the job token (which requires `contents: write` permission on the calling
+job) unless `github_token` says otherwise:

@nfebe
nfebe merged commit 8034287 into main Sep 20, 2026
4 checks passed
@nfebe
nfebe deleted the js-publish-github-token branch September 20, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant