From 7919b3f2044bcb33ed8cd159476a5bdf75667cc1 Mon Sep 17 00:00:00 2001 From: ffranr Date: Wed, 23 Oct 2024 12:02:30 +0200 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 | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cb010bba5..ccf95cb90 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ release-install: release: clean-mobile @$(call print, "Releasing lnd and lncli 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)" #? docker-release: Same as release but within a docker container to support reproducible builds on BSD/MacOS platforms docker-release: diff --git a/scripts/release.sh b/scripts/release.sh index 0f6b44cff..42a5f7d4e 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -129,11 +129,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 @@ -202,7 +214,7 @@ function build_release() { function usage() { red "Usage: " red "release.sh check-tag " - red "release.sh build-release " + red "release.sh build-release " } # Whatever sub command is passed in, we need at least 2 arguments.