Skip to content

Commit ee0b36a

Browse files
committed
scripts: make release checks git tag using script get-git-tag-name.sh
This commit modifies the release build script such that it checks the validity of the checked-out git tag by cross-referencing with the output of the `get-git-tag-name.sh` script.
1 parent c82d079 commit ee0b36a

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

make/release_flags.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RELEASE_TAGS = monitoring
2626
# from the current date.
2727
ifneq ($(tag),)
2828
VERSION_TAG = $(tag)
29-
VERSION_CHECK = ./scripts/release.sh check-tag "$(VERSION_TAG)"
29+
VERSION_CHECK = ./scripts/release.sh check-tag "$(VERSION_TAG)" "$(VERSION_GO_FILE)"
3030
endif
3131

3232
# By default we will build all systems. But with the 'sys' tag, a specific

scripts/release.sh

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ function red() {
8080

8181
# check_tag_correct makes sure the given git tag is checked out and the git tree
8282
# is not dirty.
83-
# arguments: <version-tag>
83+
# arguments: <version-tag> <version-file-path>
8484
function check_tag_correct() {
8585
local tag=$1
86+
local version_file_path=$2
8687

8788
# For automated builds we can skip this check as they will only be triggered
8889
# on tags.
@@ -102,31 +103,16 @@ function check_tag_correct() {
102103
echo "Tag $tag checked out. Git commit: $commit_hash"
103104
fi
104105

105-
# Build tapd to extract version.
106-
go build ${PKG}/cmd/tapd
106+
# Ensure that the git tag matches the version string derived from the version
107+
# file.
108+
local expected_tag
109+
expected_tag=$(./scripts/get-git-tag-name.sh "$version_file_path")
107110

108-
# Extract version command output.
109-
tapd_version_output=$(./tapd --version)
110-
111-
# Use a regex to isolate the version string.
112-
if [[ $tapd_version_output =~ $TAPD_VERSION_REGEX ]]; then
113-
# Prepend 'v' to match git tag naming scheme.
114-
tapd_version="v${BASH_REMATCH[1]}"
115-
green "version: $tapd_version"
116-
117-
# If the tapd reported version contains a suffix, remove it, so we can match
118-
# the tag properly.
119-
# shellcheck disable=SC2001
120-
tapd_version=$(echo "$tapd_version" | sed -e 's/-\(alpha\|beta\)\(\.rc[0-9]\+\)\?//g')
121-
122-
# Match git tag with tapd version.
123-
if [[ $tag != "${tapd_version}" ]]; then
124-
red "tapd version $tapd_version does not match tag $tag"
125-
exit 1
126-
fi
127-
else
128-
red "malformed tapd version output"
111+
if [[ $tag != "$expected_tag" ]]; then
112+
red "Error: tag $tag does not match git tag version string derived from $version_file_path"
129113
exit 1
114+
else
115+
green "tag $tag matches git tag version string derived from $version_file_path"
130116
fi
131117
}
132118

0 commit comments

Comments
 (0)