Skip to content

Commit 9d7b325

Browse files
committed
Dynamically extract Go version from go.mod for build task
1 parent e315ecc commit 9d7b325

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

ci/tasks/build/task.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ cd om
1111
git remote set-url origin https://github.com/pivotal-cf/om
1212
git fetch -t -P -p
1313

14-
# Kludge to get this thing buillt by go 1.22.5
15-
wget https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
16-
tar xf go1.22.5.linux-amd64.tar.gz
17-
rm go1.22.5.linux-amd64.tar.gz
14+
# Extract Go version from go.mod file
15+
GO_VERSION=$(grep -E "^go [0-9]+\.[0-9]+(\.[0-9]+)?" go.mod | awk '{print $2}')
16+
if [ -z "$GO_VERSION" ]; then
17+
echo "Failed to extract Go version from go.mod"
18+
exit 1
19+
fi
20+
21+
echo "Using Go version $GO_VERSION from go.mod"
22+
23+
# Download and install the Go version specified in go.mod
24+
wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
25+
tar xf "go${GO_VERSION}.linux-amd64.tar.gz"
26+
rm "go${GO_VERSION}.linux-amd64.tar.gz"
1827
rm -rf /usr/local/go
1928
mv go /usr/local
2029

0 commit comments

Comments
 (0)