From 260b90d1af1035803cbf6190cf011d0961def0cf Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Tue, 30 Sep 2025 11:12:22 -0300 Subject: [PATCH] release.sh: check Go version, provide GO_CMD var --- docs/release.md | 19 +++++++++++++++++++ release.sh | 23 +++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/release.md b/docs/release.md index 15782d1c..8088cc31 100644 --- a/docs/release.md +++ b/docs/release.md @@ -58,6 +58,25 @@ other tools: sudo apt-get install build-essential git make zip perl gpg ``` +You can [download](https://go.dev/dl/) and unpack Go somewhere and set variable +`GO_CMD=/path/to/go` (path to Go binary of the needed version). + +If you already have another Go version, you can install the Go version needed +for a release using the following commands: + +```bash +$ go version +go version go1.25.0 linux/amd64 +$ go install golang.org/dl/go1.24.6@latest +$ go1.24.6 download +Unpacking /home/user/sdk/go1.24.6/go1.24.6.linux-amd64.tar.gz ... +Success. You may now run 'go1.24.6' +$ go1.24.6 version +go version go1.24.6 linux/amd64 + +$ GO_CMD=/home/user/go/bin/go1.24.6 ./release.sh v0.31.3 +``` + On MacOS, you will need to install GNU tar and GNU gzip, which can be done with `brew`: diff --git a/release.sh b/release.sh index 6f898928..90a60778 100755 --- a/release.sh +++ b/release.sh @@ -27,6 +27,25 @@ function red() { echo -e "\e[0;31m${1}\e[0m" } +# Use GO_CMD from env if set, otherwise default to "go". +GO_CMD="${GO_CMD:-go}" + +# Check if the command exists. +if ! command -v "$GO_CMD" >/dev/null 2>&1; then + red "Error: Go command '$GO_CMD' not found" + exit 1 +fi + +# Make sure we have the expected Go version installed. +EXPECTED_VERSION="go1.24.6" +INSTALLED_VERSION=$("$GO_CMD" version 2>/dev/null | awk '{print $3}') +if [ "$INSTALLED_VERSION" = "$EXPECTED_VERSION" ]; then + green "Go version matches expected: $INSTALLED_VERSION" +else + red "Error: Expected Go version $EXPECTED_VERSION but found $INSTALLED_VERSION" + exit 1 +fi + TAG='' check_tag() { @@ -203,7 +222,7 @@ fi green " - Creating artifacts directory ${ARTIFACTS_DIR}" mkdir -p "$ARTIFACTS_DIR" green " - Packaging vendor to ${ARTIFACTS_DIR}/vendor.tar.gz" -go mod vendor +"$GO_CMD" mod vendor reproducible_tar_gzip vendor "${ARTIFACTS_DIR}/vendor.tar.gz" rm -r vendor @@ -248,7 +267,7 @@ for i in $SYS; do green "- Building: $OS $ARCH $ARM" for bin in loop loopd; do - env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags "$COMMITFLAGS" "github.com/lightninglabs/loop/cmd/$bin" + env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM "$GO_CMD" build -v -trimpath -ldflags "$COMMITFLAGS" "github.com/lightninglabs/loop/cmd/$bin" done cd ..