Skip to content

ci(publish): derive npm dist-tag from package version - #18

Merged
MatiasOS merged 2 commits into
openscan-explorer:mainfrom
MatiasOS:ci/npm-publish-prerelease-tag
Sep 15, 2026
Merged

MatiasOS merged 2 commits into
openscan-explorer:mainfrom
MatiasOS:ci/npm-publish-prerelease-tag

Conversation

@MatiasOS

Copy link
Copy Markdown
Member

Fixes the npm publish workflow, which fails for every prerelease. The latest failure is run 34886797034, after #17 bumped the version to 1.3.0-alpha.0:

npm error You must specify a tag using --tag when publishing a prerelease version.

Cause

The workflow runs Node 24, which ships npm 11. npm 11 won't publish a prerelease unless a tag is set explicitly. JS-DevTools/npm-publish@v4 only passes --tag when its tag input is set, and the workflow doesn't set one.

Every alpha from 1.1.0-alpha.0 to 1.2.1-alpha.0 failed in CI and was published by hand. 1.0.0 and 1.0.1 were published by this workflow through trusted publishing (OIDC), so auth works and the missing tag is the only blocker.

Changes

File Change
.github/workflows/npm-publish.yml New dist-tag step reads version from package.json and passes the tag to the action
package.json repository.url → git+https://github.com/openscan-explorer/explorer-metadata.git, the form npm was auto-correcting to (removes the publish warning)

Tag mapping

Version dist-tag
1.3.0-alpha.0 alpha
1.3.0-beta.2 beta
2.0.0-rc.1 rc
1.0.2-0 next
1.3.0 latest

This matches the tags already on npm (latest: 1.0.1, alpha: 1.2.1-alpha.0). A numeric prerelease id, which is what npm version prerelease gives without --preid, falls back to next because npm rejects 0 as a tag. The tag isn't hardcoded to alpha, so a stable release still moves latest.

Testing

  • Ran the dist-tag step as written in the workflow file against the current package.json: it outputs tag=alpha.
  • npm publish --dry-run (npm 11.6.0) reproduces the CI error. npm publish --dry-run --tag alpha publishes 1.3.0-alpha.0 under alpha with no warnings.
  • npm run validate, npm run format and npm run lint pass.

After merge

The push to main should publish 1.3.0-alpha.0 under alpha. It isn't on npm yet, so that run is the real test; please don't publish it by hand before then, or the workflow will skip it.

npm view @openscan/metadata dist-tags   # expect alpha: 1.3.0-alpha.0, latest: 1.0.1

npm 11 refuses to publish a prerelease without an explicit --tag, and
JS-DevTools/npm-publish only passes --tag when its tag input is set, so
every alpha release failed in CI.

Publish X.Y.Z-<preid>.N under <preid> (e.g. alpha), numeric preids under
next, and stable versions under latest.
Use the git+https form that npm auto-corrects to on publish.
@MatiasOS
MatiasOS requested a review from AugustoL September 15, 2026 13:41
@MatiasOS
MatiasOS merged commit c78137e into openscan-explorer:main Sep 15, 2026
3 checks passed
@MatiasOS
MatiasOS deleted the ci/npm-publish-prerelease-tag branch September 15, 2026 13:41
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