From bea46676053176661eeb71924315246e26b64b71 Mon Sep 17 00:00:00 2001 From: ffranr Date: Sat, 27 Jul 2024 00:13:21 +0100 Subject: [PATCH] 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. --- Makefile | 2 +- scripts/release.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2806fe315..ba1768423 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ release-install: release: @$(call print, "Releasing tapd and tapcli binaries.") $(VERSION_CHECK) - ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" + ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)" release-tag: @$(call print, "Adding release tag.") diff --git a/scripts/release.sh b/scripts/release.sh index 3d28a9542..74667ed3a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -118,11 +118,23 @@ function check_tag_correct() { # build_release builds the actual release binaries. # arguments: +# function build_release() { local tag=$1 local sys=$2 local buildtags=$3 local ldflags=$4 + local goversion=$5 + + # Check if the active Go version matches the specified Go version. + active_go_version=$(go version | awk '{print $3}' | sed 's/go//') + if [ "$active_go_version" != "$goversion" ]; then + echo "Error: active Go version ($active_go_version) does not match \ +required Go version ($goversion)." + exit 1 + fi + + echo "Building release for tag $tag with Go version $goversion" green " - Packaging vendor" go mod vendor