Skip to content

Publish from CI on a version tag - #7

Merged
stromcom merged 1 commit into
masterfrom
ci/publish-workflow
Aug 14, 2026
Merged

Publish from CI on a version tag#7
stromcom merged 1 commit into
masterfrom
ci/publish-workflow

Conversation

@stromcom

Copy link
Copy Markdown
Owner

Why

Releasing depended on whoever happened to hold a working npm login. That is how 0.3.0 ended up tagged in git but never published to npm — the registry still serves 0.1.0 as latest, with 0.2.0 missing too.

What

.github/workflows/publish.yml — pushing a bare version tag (0.3.1, matching this repo's existing tag style) runs lint, format:check, test and build, then publishes.

  • Tag/version guard. The job fails if the tag does not equal package.json's version. This is precisely the 0.3.0 failure mode: tag said 0.3.0, package.json said 0.2.0.
  • Provenance. id-token: write + --provenance attaches an attestation linking the tarball to this commit and workflow.
  • publishConfig.access: "public" in package.json, so a publish can never silently fall back to a restricted one — scoped packages default to restricted.

Setup needed before the first run

Add a repository secret NPM_TOKEN — an npm Automation token (Access Tokens → Generate New Token → Automation) for an account with publish rights on the @stromcom scope. Granular tokens work too; a "Read-only" token does not.

If you would rather not store a token at all, npm Trusted Publishing (OIDC) is the alternative: configure this repo and workflow as a trusted publisher on npmjs.com and drop the NODE_AUTH_TOKEN env. Happy to switch it over.

Releasing from here

npm version <patch|minor|major> --no-git-tag-version   # or edit package.json
git commit -am "chore(release): X.Y.Z" && <merge to master>
git tag X.Y.Z && git push origin X.Y.Z

Master is already at 0.3.1, so once this lands, pushing the 0.3.1 tag publishes it.

Releases depended on whoever had a working npm login locally, which is
also how 0.3.0 ended up tagged but never published. Pushing a version tag
now runs lint, format, tests and build, checks the tag against
package.json, and publishes with provenance.

publishConfig.access=public is set so a plain 'npm publish' cannot fall
back to a restricted publish -- scoped packages default to restricted.
@stromcom
stromcom merged commit 26699b4 into master Aug 14, 2026
3 checks passed
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