Skip to content

fix: dynamically increment prerelease versions in publish.sh#1932

Open
inlined wants to merge 2 commits into
masterfrom
inlined.fix-publish-prerelease
Open

fix: dynamically increment prerelease versions in publish.sh#1932
inlined wants to merge 2 commits into
masterfrom
inlined.fix-publish-prerelease

Conversation

@inlined

@inlined inlined commented Jul 16, 2026

Copy link
Copy Markdown
Member

Description

Fixes an issue in scripts/publish.sh where prerelease publishing (e.g. running with --prerelease) would fail if rc.0 was already published on npm for that target version series, since it always bumped from the stable version. It now dynamically checks npm for any existing prerelease versions of the target version series, and performs a prerelease increment (e.g., to rc.1) if one exists.

Newly assumes the jq command exists to avoid silly node scripts (will need to test in prod or build a new container). Now handles gh not existing since it didn't in the past.

Release Notes

relnote: chore: improve release script

@inlined
inlined force-pushed the inlined.fix-publish-prerelease branch from 3b5481e to e1aa47a Compare July 16, 2026 22:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the prerelease versioning logic in scripts/publish.sh to check npm for existing prerelease versions in the target range and increment them if found, rather than always starting from the stable version. The reviewer noted that parsing the raw output of npm view with tail and grep is fragile and prone to errors due to output formatting variations, sorting assumptions, and a hardcoded regex. They suggested a more robust approach using Node.js and the semver package to parse the JSON output safely.

Comment thread scripts/publish.sh Outdated
@inlined
inlined force-pushed the inlined.fix-publish-prerelease branch 4 times, most recently from 747ba4c to 8ebf2f0 Compare July 20, 2026 22:00
@inlined
inlined force-pushed the inlined.fix-publish-prerelease branch from 8ebf2f0 to 2a51ea7 Compare July 20, 2026 22:40
Comment thread scripts/publish.sh
STABLE_VERSION=$(npm view "$PACKAGE_NAME" version)

# Find the absolute latest version overall on npm (including prereleases)
LATEST_VERSION=$(npm view "$PACKAGE_NAME" versions --json | grep -oE '[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?' | tail -n 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was doing some diving to fully understand this. It totally works and I'm fine merging it. Gemini thinks if we're already using jq it'd be slightly more robust to use it:

LATEST_VERSION=$(npm view "$PACKAGE_NAME" versions --json | jq -r '[.[] | select(test("^[0-9]+\\.[0-9]+\\.[0-9]+(-rc\\.[0-9]+)?$"))] | .[-1]')

It does all the stripping so you just reduce to testing the version numbers to be fair... but I kinda doubt npm view versions --json is going to change much.

Comment thread scripts/publish.sh

# 3. Stateless Version Discovery
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_NAME=$(jq -r '.name' package.json)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is it safe to assuming jq will be installed? It wasn't on my cloudtop for example (though I've now installed it).

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.

3 participants