Skip to content

Commit bea4667

Browse files
committed
makefile+scripts: add Go version check to release command
This commit updates `scripts/release.sh` to include a check for the correct Go version before executing the release build. This ensures that the release binaries are built with the specified Go version, maintaining consistency and integrity for developer signatures.
1 parent 0dfdb12 commit bea4667

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ release-install:
118118
release:
119119
@$(call print, "Releasing tapd and tapcli binaries.")
120120
$(VERSION_CHECK)
121-
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)"
121+
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)"
122122

123123
release-tag:
124124
@$(call print, "Adding release tag.")

scripts/release.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,23 @@ function check_tag_correct() {
118118

119119
# build_release builds the actual release binaries.
120120
# arguments: <version-tag> <build-system(s)> <build-tags> <ldflags>
121+
# <go-version>
121122
function build_release() {
122123
local tag=$1
123124
local sys=$2
124125
local buildtags=$3
125126
local ldflags=$4
127+
local goversion=$5
128+
129+
# Check if the active Go version matches the specified Go version.
130+
active_go_version=$(go version | awk '{print $3}' | sed 's/go//')
131+
if [ "$active_go_version" != "$goversion" ]; then
132+
echo "Error: active Go version ($active_go_version) does not match \
133+
required Go version ($goversion)."
134+
exit 1
135+
fi
136+
137+
echo "Building release for tag $tag with Go version $goversion"
126138

127139
green " - Packaging vendor"
128140
go mod vendor

0 commit comments

Comments
 (0)