From 202ff374394b8ecf01194d9546bf0db6be058731 Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 21 Sep 2026 23:39:01 +0100 Subject: [PATCH] fix(version): look up the monthly tag without the v prefix tools/version.sh only recognized a 'v'-prefixed monthly tag (v26.09), but the project tags are bare (26.09), matching the convention sas_py's setuptools-git-versioning builds PyPI versions from. As a result the rolling component was always 00 and the .deb/CMake version stayed 26.09.00 while main kept moving. Look up the monthly tag as 'YY.MM' first and fall back to 'vYY.MM'. Verified: with 5 commits after 26.09 the script now reports 26.09.05 (previously 26.09.00); missing tag still reports 26.09.00; a v-prefixed tag alone still works via the fallback. Co-authored-by: openhands --- tools/version.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tools/version.sh b/tools/version.sh index 8bd1686..4eb2309 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -1,22 +1,34 @@ #!/usr/bin/env bash # Compute the rolling project version: YY.MM.NN # YY.MM : year.month of the current date (e.g. 26.09) -# NN : number of commits since the version tag vYY.MM (e.g. v26.09). -# 00 when the tag does not exist yet. -# Output: 26.09.00 +# NN : number of commits since the monthly version tag (e.g. 26.09). +# 00 when no such tag exists yet. +# The monthly tag is looked up without a "v" prefix (the project +# convention -- the raw tag name is what sas_py's +# setuptools-git-versioning turns into the PyPI version); a "v"-prefixed +# tag is accepted as a fallback. +# Output: 26.09.05 set -euo pipefail YYMM="$(date +%y.%m)" -TAG="v${YYMM}" +# Echo the first existing monthly tag (bare YY.MM, then v-prefixed). +find_version_tag() { + local t + for t in "${YYMM}" "v${YYMM}"; do + if git rev-parse --verify "refs/tags/${t}" >/dev/null 2>&1; then + printf '%s\n' "${t}" + return 0 + fi + done + return 1 +} + +NN=0 if command -v git >/dev/null 2>&1 && git rev-parse --git-dir >/dev/null 2>&1; then - if git rev-parse --verify "refs/tags/${TAG}" >/dev/null 2>&1; then + if TAG="$(find_version_tag)"; then NN="$(git rev-list "${TAG}..HEAD" --count 2>/dev/null || echo 0)" - else - NN=0 fi -else - NN=0 fi printf '%s.%02d\n' "${YYMM}" "${NN:-0}"