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