From 5d10b5ed1a98202280eab96292978328d52134c4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 1 Apr 2022 11:33:55 +0200 Subject: [PATCH] fix: correct go.sh (#55) --- linux/ubuntu/scripts/go.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/linux/ubuntu/scripts/go.sh b/linux/ubuntu/scripts/go.sh index d8a79e3..efd4312 100755 --- a/linux/ubuntu/scripts/go.sh +++ b/linux/ubuntu/scripts/go.sh @@ -7,7 +7,7 @@ set -Eeuxo pipefail printf "\n\tšŸ‹ Installing Go(lang) šŸ‹\t\n" -JSON=$(wget -qO- "$(jq -r '.toolcache[] | select(.name == "go") | .url' "/imagegeneration/toolset.json")" | jq --compact-output) +wget -qO- "$(jq -r '.toolcache[] | select(.name == "go") | .url' "/imagegeneration/toolset.json")" > "/tmp/go-toolset.json" go_arch() { case "$(uname -m)" in @@ -18,11 +18,18 @@ go_arch() { for V in $(jq -r '.toolcache[] | select(.name == "go") | .versions[]' "/imagegeneration/toolset.json"); do printf "\n\tšŸ‹ Installing GO=%s šŸ‹\t\n" "${V}" - VER=$(echo "${JSON}" | jq "[.[] | select(.version|test(\"^${V}\"))][0].version" -r) + VER=$(jq -r "[.[] | select(.version|test(\"^${V}\"))][0].version" "/tmp/go-toolset.json") GOPATH="$AGENT_TOOLSDIRECTORY/go/${VER}/x64" mkdir -v -m 0777 -p "$GOPATH" - wget -qO- "https://golang.org/dl/go${VER}.linux-$(go_arch).tar.gz" | tar -zxf - --strip-components=1 -C "$GOPATH" + DL_VER="${VER}" + # hack + # TODO: i hate shell scripts, please can I have powershell on linux and no, python is not a solution, it should die + # TODO: write own thing to get links from go.dev and versions from actions/go-versions, mash it together, ?????, works + if [[ "$(echo ${VER} | cut -d. -f3)" == "0" ]]; then + DL_VER=$(echo "${VER}" | cut -d. -f-2) + fi + wget -qO- "https://golang.org/dl/go${DL_VER}.linux-$(go_arch).tar.gz" | tar -zxf - --strip-components=1 -C "$GOPATH" # ENVVAR="${V//\./_}" # echo "${ENVVAR}=${GOPATH}" >>/etc/environment @@ -30,7 +37,7 @@ for V in $(jq -r '.toolcache[] | select(.name == "go") | .versions[]' "/imagegen printf "\n\tšŸ‹ Installed GO šŸ‹\t\n" "$GOPATH/bin/go" version - if [[ "${V}" == "1.15" ]]; then + if [[ "${V}" == "1.15.*" ]]; then ln -s "$GOPATH/bin/*" /usr/bin/ fi done