From 3e549e1349462093f3f8c60dfd31152a0b6b4449 Mon Sep 17 00:00:00 2001 From: Anoop Narang Date: Thu, 10 Sep 2026 19:56:31 +0530 Subject: [PATCH 1/3] fix(release): read the version after checking out the base `cmd_prepare` read the current version before switching to the base branch, so the bump was computed from whatever branch the script happened to be on. Running it from any other branch cuts a release numbered off unrelated history. `scripts/release.sh` in hotdata-ibis already has this ordering; this brings the rest in line. --- scripts/release.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 17a5f63..182478b 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -124,6 +124,15 @@ cmd_prepare() { ensure_clean local current new base branch + base="$(default_branch)" + git fetch origin "$base" + git checkout "$base" + git pull --ff-only origin "$base" + ensure_clean + + # Read the version from the base branch, not from whatever branch the script + # was invoked on. The bump is computed from it, so reading it first numbers + # the release off unrelated history. current="$(get_version)" [[ -n "$current" ]] || die "could not read current version from Cargo.toml" if [[ "$bump" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then @@ -133,12 +142,6 @@ cmd_prepare() { fi [[ "$new" != "$current" ]] || die "new version ($new) equals current ($current)" - base="$(default_branch)" - git fetch origin "$base" - git checkout "$base" - git pull --ff-only origin "$base" - ensure_clean - set_version "$new" update_changelog "$new" From dbd3650113ab5b089a1462f0423daaa4b327aa4f Mon Sep 17 00:00:00 2001 From: Anoop Narang Date: Thu, 10 Sep 2026 20:00:42 +0530 Subject: [PATCH 2/3] fix(release): validate the bump kind before switching branches Moving the version read below the checkout also moved the bump-kind validation, which lives inside bump_version. A typo then switched the caller to the base branch before failing. Check the argument next to the existing emptiness check, using the same pattern the explicit-version branch already accepts, so an argument error exits without side effects as it did before. --- scripts/release.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/release.sh b/scripts/release.sh index 182478b..1ff2a10 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -118,6 +118,10 @@ update_changelog() { cmd_prepare() { local bump="${1:-}" [[ -n "$bump" ]] || { usage; die "missing bump kind or explicit version"; } + # Validate before any branch switch below, so a typo exits without moving the + # caller off the branch they invoked from. + [[ "$bump" =~ ^(patch|minor|major|[0-9]+\.[0-9]+\.[0-9]+)$ ]] \ + || { usage; die "unknown bump kind: $bump"; } need gh need python3 need git From 556452c5aafc8680d6b7bcf5d8596eebf1df739e Mon Sep 17 00:00:00 2001 From: Anoop Narang Date: Thu, 10 Sep 2026 20:04:19 +0530 Subject: [PATCH 3/3] refactor(release): one definition of the version pattern The explicit-version regex appeared in both the argument check and the branch that takes the argument verbatim, so a change to the accepted format had to be made twice. Hoist it to VERSION_RE, alongside BUMP_KIND_RE. Also narrow the comment above the check: an unchanged version and a pre-release suffix are found from the base branch version, so those necessarily fail after the checkout and the comment should not imply otherwise. --- scripts/release.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 1ff2a10..81e5081 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -7,6 +7,11 @@ cd "$ROOT" PKG_NAME="hotdata" die() { echo "error: $*" >&2; exit 1; } + +# The one definition of an explicit version, shared by the argument check and +# the branch that takes the argument verbatim, so the two cannot drift apart. +readonly VERSION_RE='^[0-9]+\.[0-9]+\.[0-9]+$' +readonly BUMP_KIND_RE='^(patch|minor|major)$' need() { command -v "$1" >/dev/null 2>&1 || die "$1 is required"; } usage() { @@ -118,9 +123,11 @@ update_changelog() { cmd_prepare() { local bump="${1:-}" [[ -n "$bump" ]] || { usage; die "missing bump kind or explicit version"; } - # Validate before any branch switch below, so a typo exits without moving the - # caller off the branch they invoked from. - [[ "$bump" =~ ^(patch|minor|major|[0-9]+\.[0-9]+\.[0-9]+)$ ]] \ + # Check the argument before any branch switch below, so a typo exits without + # moving the caller off the branch they invoked from. Failures that depend on + # the base branch's version — an unchanged version, a pre-release suffix — + # can only be found after the checkout. + [[ "$bump" =~ $BUMP_KIND_RE || "$bump" =~ $VERSION_RE ]] \ || { usage; die "unknown bump kind: $bump"; } need gh need python3 @@ -139,7 +146,7 @@ cmd_prepare() { # the release off unrelated history. current="$(get_version)" [[ -n "$current" ]] || die "could not read current version from Cargo.toml" - if [[ "$bump" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + if [[ "$bump" =~ $VERSION_RE ]]; then new="$bump" else new="$(bump_version "$bump" "$current")"