Publish to npm on tag push and derive version from tag#37
Merged
Conversation
Replace the manual main-branch publish flow with tag-driven releases. Pushing a tag like `v2.0.0` now triggers the workflow, writes the stripped tag (e.g. `2.0.0`) into package.json via `npm pkg set` at run time, and publishes. Tags containing a hyphen (e.g. `v2.0.0-beta.1`) are treated as prereleases and published under the `next` dist-tag so they do not move `latest`. This removes the need to bump the version in package.json by hand before each release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v2.0.0now triggers the workflow and publishes to npm; merges tomainno longer publish.npm pkg set version=..., sopackage.jsonno longer needs a manual bump before each release.v2.0.0-beta.1) are published under thenextdist-tag, leavinglatestpointing at the current stable.Why
Today the workflow publishes on every push to
main, which:package.jsonversion bump in a separate commit before the release commit, easy to forget or get wrong.latestdist-tag for allnpm install chdbusers.Driving releases from semver tags is the standard npm/Node ecosystem flow and resolves all three.
How to release after this PR
Or use GitHub's Releases → Draft a new release UI with the same tag name.
Test plan
main→ CI runs build/tests on the matrix, no publish step executes (verify in Actions logs).v0.0.0-test.1to a fork or scratch tag → workflow runs, theSet version from tagstep printsPublishing version: 0.0.0-test.1, and thePublish to npmstep uses--tag next. (Drop the tag without actually publishing if testing pre-merge.)v2.0.0) once theNPM_TOKENsecret is verified valid.Notes / follow-ups
404publish failure on the2.0.0push tomain; that appears to be theNPM_TOKENsecret being expired or no longer scoped to thechdbpackage, and needs to be rotated separately on npmjs.com → GitHub repo secrets.package.json'sversionfield will drift from the published version after this change. That is expected and harmless; the git tag is the source of truth. If you prefer to keep them in sync, usenpm version <x.y.z>locally (which commits + tags in one shot) before pushing.Made with Cursor