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.
This commit is contained in:
ffranr authored and Oliver Gugger committed 2024-10-23 13:34:35 +02:00
1 parent b4ef22bf47
commit 7919b3f204
2 files changed
+14 -2

No files matched your search

+13 -1
View File
@@ -129,11 +129,23 @@ function check_tag_correct() {
# build_release builds the actual release binaries.
# arguments: <version-tag> <build-system(s)> <build-tags> <ldflags>
# <go-version>
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 <version-tag>"
red "release.sh build-release <version-tag> <build-system(s)> <build-tags> <ldflags>"
red "release.sh build-release <version-tag> <build-system(s)> <build-tags> <ldflags> <go-version>"
}
# Whatever sub command is passed in, we need at least 2 arguments.