From 69c38acd25640e6a8bed9302aeb97a2182d93438 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 1 Nov 2025 12:54:32 -0300 Subject: [PATCH] release.sh: fix for the case of multiple tags ./release.sh v0.31.5-beta fails as of tag v0.31.5-beta: tag v0.31.5-beta not checked out This is because it checks the Git tag with `git describe`, but the current commit has multiple tags and `git describe` returns swapserverrpc/v1.0.18 instead of expected v0.31.5-beta. In this commit this edge case is addressed. --- release.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/release.sh b/release.sh index 77dbfad67..8f8eadab9 100755 --- a/release.sh +++ b/release.sh @@ -59,17 +59,11 @@ check_tag() { TAG=$1 - # If a tag is specified, ensure that tag is present and checked out. - if [[ $TAG != $(git describe --abbrev=10) ]]; then - red "tag $TAG not checked out" - exit 1 - fi - # Verify that it is signed if it is a real tag. If the tag looks like the # output of "git describe" for an untagged commit, skip verification. # The pattern is: --g # Example: "v0.31.2-beta-122-g8c6b73c". - if [[ $TAG =~ -[0-9]+-g([0-9a-f]{10})$ ]]; then + if [[ $TAG =~ -[0-9]+-g([0-9a-f]{7,40})$ ]]; then # This looks like a "git describe" output. Make sure the hash # described is a prefix of the current commit. DESCRIBED_HASH=${BASH_REMATCH[1]} @@ -82,6 +76,25 @@ check_tag() { return fi + # Release tags must start with 'v' (for example v0.31.5-beta). + if [[ $TAG != v* ]]; then + red "tag $TAG must start with 'v'" + exit 1 + fi + + # Ensure the tag exists in the repository. + if ! git show-ref --verify --quiet "refs/tags/$TAG"; then + red "tag $TAG not found" + exit 1 + fi + + # Ensure the current commit is tagged with the requested tag, even when + # multiple tags point at HEAD. + if ! git tag --points-at HEAD | grep -Fxq "$TAG"; then + red "tag $TAG not checked out on the current commit" + exit 1 + fi + if ! git verify-tag $TAG; then red "tag $TAG not signed" exit 1