Skip to content

Commit 260b90d

Browse files
committed
release.sh: check Go version, provide GO_CMD var
1 parent 6d8872f commit 260b90d

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

docs/release.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ other tools:
5858
sudo apt-get install build-essential git make zip perl gpg
5959
```
6060

61+
You can [download](https://go.dev/dl/) and unpack Go somewhere and set variable
62+
`GO_CMD=/path/to/go` (path to Go binary of the needed version).
63+
64+
If you already have another Go version, you can install the Go version needed
65+
for a release using the following commands:
66+
67+
```bash
68+
$ go version
69+
go version go1.25.0 linux/amd64
70+
$ go install golang.org/dl/go1.24.6@latest
71+
$ go1.24.6 download
72+
Unpacking /home/user/sdk/go1.24.6/go1.24.6.linux-amd64.tar.gz ...
73+
Success. You may now run 'go1.24.6'
74+
$ go1.24.6 version
75+
go version go1.24.6 linux/amd64
76+
77+
$ GO_CMD=/home/user/go/bin/go1.24.6 ./release.sh v0.31.3
78+
```
79+
6180
On MacOS, you will need to install GNU tar and GNU gzip, which can be done with
6281
`brew`:
6382

release.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ function red() {
2727
echo -e "\e[0;31m${1}\e[0m"
2828
}
2929

30+
# Use GO_CMD from env if set, otherwise default to "go".
31+
GO_CMD="${GO_CMD:-go}"
32+
33+
# Check if the command exists.
34+
if ! command -v "$GO_CMD" >/dev/null 2>&1; then
35+
red "Error: Go command '$GO_CMD' not found"
36+
exit 1
37+
fi
38+
39+
# Make sure we have the expected Go version installed.
40+
EXPECTED_VERSION="go1.24.6"
41+
INSTALLED_VERSION=$("$GO_CMD" version 2>/dev/null | awk '{print $3}')
42+
if [ "$INSTALLED_VERSION" = "$EXPECTED_VERSION" ]; then
43+
green "Go version matches expected: $INSTALLED_VERSION"
44+
else
45+
red "Error: Expected Go version $EXPECTED_VERSION but found $INSTALLED_VERSION"
46+
exit 1
47+
fi
48+
3049
TAG=''
3150

3251
check_tag() {
@@ -203,7 +222,7 @@ fi
203222
green " - Creating artifacts directory ${ARTIFACTS_DIR}"
204223
mkdir -p "$ARTIFACTS_DIR"
205224
green " - Packaging vendor to ${ARTIFACTS_DIR}/vendor.tar.gz"
206-
go mod vendor
225+
"$GO_CMD" mod vendor
207226
reproducible_tar_gzip vendor "${ARTIFACTS_DIR}/vendor.tar.gz"
208227
rm -r vendor
209228

@@ -248,7 +267,7 @@ for i in $SYS; do
248267

249268
green "- Building: $OS $ARCH $ARM"
250269
for bin in loop loopd; do
251-
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags "$COMMITFLAGS" "github.com/lightninglabs/loop/cmd/$bin"
270+
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM "$GO_CMD" build -v -trimpath -ldflags "$COMMITFLAGS" "github.com/lightninglabs/loop/cmd/$bin"
252271
done
253272
cd ..
254273

0 commit comments

Comments
 (0)