Skip to content

Commit 3150aa5

Browse files
committed
release.sh: fix building untagged commits
To test "make docker-release" it is convenient to pass a regular commit to it (an output of `git describe`). In this commit release.sh is changed to detect such "tags" and skip tag signature verification for it. Also if release.sh is used without an argument, a unique directory name is generated from the current time.
1 parent 8a35705 commit 3150aa5

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

release.sh

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
# Exit on errors.
1111
set -e
1212

13-
# If no tag specified, use date + version otherwise use tag.
14-
if [[ $1x = x ]]; then
15-
DATE=`date +%Y%m%d`
16-
VERSION="01"
17-
TAG=$DATE-$VERSION
18-
else
13+
TAG=''
14+
15+
check_tag() {
16+
# If no tag specified, use date + version otherwise use tag.
17+
if [[ $1x = x ]]; then
18+
TAG=`date +%Y%m%d-%H%M%S`
19+
20+
return
21+
fi
22+
1923
TAG=$1
2024

2125
# If a tag is specified, ensure that tag is present and checked out.
@@ -24,8 +28,24 @@ else
2428
exit 1
2529
fi
2630

27-
# Verify that it is signed.
28-
if ! git verify-tag $TAG; then
31+
# Verify that it is signed if it is a real tag. If the tag looks like the
32+
# output of "git describe" for an untagged commit, skip verification.
33+
# The pattern is: <tag_name>-<number_of_commits>-g<abbreviated_commit_hash>
34+
# Example: "v0.31.2-beta-122-g8c6b73c".
35+
if [[ $TAG =~ -[0-9]+-g([0-9a-f]+)$ ]]; then
36+
# This looks like a "git describe" output. Make sure the hash
37+
# described is a prefix of the current commit.
38+
DESCRIBED_HASH=${BASH_REMATCH[1]}
39+
CURRENT_HASH=$(git rev-parse HEAD)
40+
if [[ $CURRENT_HASH != $DESCRIBED_HASH* ]]; then
41+
echo "Described hash $DESCRIBED_HASH is not a prefix of current commit $CURRENT_HASH"
42+
exit 1
43+
fi
44+
45+
return
46+
fi
47+
48+
if ! git verify-tag $TAG; then
2949
echo "tag $TAG not signed"
3050
exit 1
3151
fi
@@ -52,7 +72,9 @@ else
5272
echo "malformed loop version output"
5373
exit 1
5474
fi
55-
fi
75+
}
76+
77+
check_tag $1
5678

5779
go mod vendor
5880
tar -cvzf vendor.tar.gz vendor

0 commit comments

Comments
 (0)