From 8c3c7881e19d71b07bab919ca9f0102960d4a0df Mon Sep 17 00:00:00 2001 From: Oleg Samarin Date: Tue, 14 Apr 2026 22:19:33 +0300 Subject: [PATCH] Fixed release tag landing on wrong commit and wrong version number Previously the tag was created before the CHANGELOG auto-edit commit, so: 1. "git tag --points-at HEAD" in Calculate version found nothing (HEAD had advanced to the CHANGELOG commit), causing RELEASE=OFF and the release to be skipped entirely. 2. The tag name did not match the commit count from the previous tag, since the CHANGELOG commit adds one more commit on top of HEAD. Fix: commit CHANGELOG first, then tag HEAD (+1 to account for the new commit), then push both. FULL_VER is now recomputed with +1 inside the release branch so the patch number stays consistent. Co-Authored-By: Claude Opus 4.6 --- build-scripts/autotag.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/build-scripts/autotag.sh b/build-scripts/autotag.sh index 0942b6e3..41ffeb83 100755 --- a/build-scripts/autotag.sh +++ b/build-scripts/autotag.sh @@ -69,16 +69,27 @@ if [[ "$CHANGELOG_MM" == "$MM" ]]; then git commit -m "Released ${RELEASE_TAG}" git push origin HEAD else - # Fresh release signal: create new release tag + # Fresh release signal: create new release tag. + # +1 because we are about to add the CHANGELOG commit on top of HEAD, + # and the tag must land on that commit so its name matches the commit count. + if [[ -n "$RELEASE_TAG" ]]; then + START_PATCH=$(echo "$RELEASE_TAG" | cut -d. -f3) + N=$(git rev-list "${RELEASE_TAG}..HEAD" --count) + FULL_VER="${MM}.$((START_PATCH + N + 1))" + else + N=$(git rev-list "${BASE_TAG}..HEAD" --count) + FULL_VER="${MM}.$((N + 1))" + fi echo "Release signal: creating tag $FULL_VER" sed '0,/^#/d;/^#/Q' "$CHANGELOG" > "$RELEASE_NOTES" || echo "Release $FULL_VER" > "$RELEASE_NOTES" - git tag "$FULL_VER" - git push origin "$FULL_VER" # Auto-edit CHANGELOG: replace "# MM (date)" with "# FULL_VER (date)" to clear the release signal sed -i "s|^# ${MM_ESCAPED} |# ${FULL_VER} |" "$CHANGELOG" git add "$CHANGELOG" git commit -m "Released ${FULL_VER}" + # Tag the CHANGELOG commit so "git tag --points-at HEAD" finds it in Calculate version + git tag "$FULL_VER" git push origin HEAD + git push origin "$FULL_VER" fi fi