File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,24 @@ if [ -z "$GOVERSION" ]; then
1111 exit 1
1212fi
1313
14+
1415export PATH=" /snap/bin:$PATH "
1516GO_MAJOR_MINOR=$( echo ${GOVERSION} | cut -d ' .' -f1,2)
16- sudo snap refresh go --channel=" ${GO_MAJOR_MINOR} /stable" || sudo snap install go --channel=" ${GO_MAJOR_MINOR} /stable" --classic
17+ if sudo snap refresh go --channel=" ${GO_MAJOR_MINOR} /stable" || sudo snap install go --channel=" ${GO_MAJOR_MINOR} /stable" --classic; then
18+ echo " Successfully installed Go ${GO_MAJOR_MINOR} "
19+ else
20+ # If specific version installation fails, install latest available
21+ echo " Failed to install Go ${GO_MAJOR_MINOR} , installing latest available version"
22+ if sudo snap refresh go --channel=latest/stable || sudo snap install go --channel=latest/stable --classic; then
23+ echo " Successfully installed latest Go version: $( go version) "
24+ # Export GOTOOLCHAIN to use the expected version
25+ # Note: this is a hack which avoid breaking the CI if for some reason snap go is behind the required version for
26+ # Juju. It is not something that should happens regularly, and whenever the snap go is available, this hack won't
27+ # be used.
28+ export GOTOOLCHAIN=" go${GOVERSION} .0+auto"
29+ echo " Exported GOTOOLCHAIN=${GOTOOLCHAIN} "
30+ fi
31+ fi
1732
1833# TODO - fix this workaround
1934# As we clone the full history (can't shallow clone otherwise queued jobs miss
You can’t perform that action at this time.
0 commit comments