From 5fac7777c9f96345e03b264f4676325df56a431e Mon Sep 17 00:00:00 2001 From: sabith Date: Wed, 11 Nov 2026 18:55:33 -0800 Subject: [PATCH] fix: derive last release tag from semver tags only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git describe --tags --abbrev=0 can return the moving major tag (v1) instead of a semver tag — it did on main after v0.2.0, crashing the classifier with AttributeError and blocking the Release workflow. Query semver tags merged into the target instead, and fail loudly in classify-commits.py if a non-semver tag ever reaches bump_version. --- .github/scripts/classify-commits.py | 4 ++++ .github/scripts/cut-release.sh | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/scripts/classify-commits.py b/.github/scripts/classify-commits.py index b9e80ec..40109e1 100644 --- a/.github/scripts/classify-commits.py +++ b/.github/scripts/classify-commits.py @@ -62,6 +62,10 @@ def classify(subject: str) -> str: def bump_version(last: str, kinds: set) -> str: m = re.match(r"v?(\d+)\.(\d+)\.(\d+)", last) + if m is None: + # Guard: a non-semver tag (e.g. the moving major tag "v1") reached this + # far once and produced an opaque traceback; fail loudly instead. + sys.exit(f"error: CUT_LAST_TAG is not a semver tag: {last!r}") major, minor, patch = (int(m.group(i)) for i in (1, 2, 3)) if "breaking" in kinds or "minor" in kinds: minor, patch = minor + 1, 0 diff --git a/.github/scripts/cut-release.sh b/.github/scripts/cut-release.sh index e9a4d20..4a02754 100755 --- a/.github/scripts/cut-release.sh +++ b/.github/scripts/cut-release.sh @@ -43,7 +43,10 @@ if ! git rev-parse -q --verify "${sha}^{commit}" >/dev/null; then exit 1 fi -last_tag=$(git describe --tags --abbrev=0 "${sha}" 2>/dev/null || true) +# Last *semver* tag reachable from the target. Do NOT use "git describe +# --tags --abbrev=0": the moving major tag (v1) is also a plain tag and +# describe may return it (it did: "v1" is not a version we can bump from). +last_tag=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --merged "$sha" --sort=-v:refname | head -1) if [ -z "$last_tag" ]; then if [ -z "$version" ]; then echo "::error::no previous tag to derive from; set RELEASE_VERSION explicitly" >&2