mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 21:38:13 +00:00
Install Go to hostedtoolcache directory on Ubuntu image (#848)
* Move go location to the toolcache
This commit is contained in:
committed by
GitHub
parent
ceef6d41d6
commit
fad0a6e41d
@@ -13,8 +13,8 @@ golangTags="/tmp/golang_tags.json"
|
||||
# $2=IsDefaultVersion (true or false)
|
||||
function InstallGo () {
|
||||
version=$( getFullGoVersion $1 )
|
||||
downloadVersion=$version.linux-amd64.tar.gz
|
||||
goFolder=/usr/local/go$1
|
||||
downloadVersion="go$version.linux-amd64.tar.gz"
|
||||
goFolder="$AGENT_TOOLSDIRECTORY/go/$version/x64"
|
||||
|
||||
echo "Install Go $version"
|
||||
curl -sL https://dl.google.com/go/${downloadVersion} -o ${downloadVersion}
|
||||
@@ -22,7 +22,10 @@ function InstallGo () {
|
||||
tar -C $goFolder -xzf $downloadVersion --strip-components=1 go
|
||||
rm $downloadVersion
|
||||
echo "GOROOT_${1//./_}_X64=$goFolder" | tee -a /etc/environment
|
||||
DocumentInstalledItem "Go $1 ($($goFolder/bin/go version))"
|
||||
DocumentInstalledItem "Go $version ($($goFolder/bin/go version))"
|
||||
|
||||
# Create symlink in old location /usr/local/go<version> to new location
|
||||
ln -s $goFolder /usr/local/go$version
|
||||
|
||||
# If this version of Go is to be the default version,
|
||||
# symlink it into the path and point GOROOT to it.
|
||||
@@ -37,8 +40,8 @@ function getFullGoVersion () {
|
||||
local pattern="refs/tags/go$1([.0-9]{0,3})$"
|
||||
local query='[.[] | select( .ref | test($pattern))] | .[-1] | .ref'
|
||||
refValue=$(jq --arg pattern "$pattern" "$query" $golangTags)
|
||||
version=$(echo "$refValue" | cut -d '/' -f 3)
|
||||
version=$(echo "${version//\"}") # go1.12.17
|
||||
version=$(echo "$refValue" | cut -d '/' -f 3 | awk -F 'go' '{print $2}')
|
||||
version=$(echo "${version//\"}") # 1.12.17
|
||||
echo $version
|
||||
}
|
||||
|
||||
|
||||
@@ -251,19 +251,6 @@
|
||||
],
|
||||
"execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"{{template_dir}}/scripts/installers/go.sh"
|
||||
],
|
||||
"environment_vars": [
|
||||
"METADATA_FILE={{user `metadata_file`}}",
|
||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}",
|
||||
"GO_VERSIONS={{user `go_versions`}}",
|
||||
"GO_DEFAULT={{user `go_default`}}"
|
||||
],
|
||||
"execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "{{template_dir}}/toolcache-1604.json",
|
||||
@@ -292,6 +279,19 @@
|
||||
],
|
||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"{{template_dir}}/scripts/installers/go.sh"
|
||||
],
|
||||
"environment_vars": [
|
||||
"METADATA_FILE={{user `metadata_file`}}",
|
||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}",
|
||||
"GO_VERSIONS={{user `go_versions`}}",
|
||||
"GO_DEFAULT={{user `go_default`}}"
|
||||
],
|
||||
"execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts":[
|
||||
|
||||
@@ -255,19 +255,6 @@
|
||||
],
|
||||
"execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"{{template_dir}}/scripts/installers/go.sh"
|
||||
],
|
||||
"environment_vars": [
|
||||
"METADATA_FILE={{user `metadata_file`}}",
|
||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}",
|
||||
"GO_VERSIONS={{user `go_versions`}}",
|
||||
"GO_DEFAULT={{user `go_default`}}"
|
||||
],
|
||||
"execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "{{template_dir}}/toolcache-1804.json",
|
||||
@@ -296,6 +283,19 @@
|
||||
],
|
||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"{{template_dir}}/scripts/installers/go.sh"
|
||||
],
|
||||
"environment_vars": [
|
||||
"METADATA_FILE={{user `metadata_file`}}",
|
||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}",
|
||||
"GO_VERSIONS={{user `go_versions`}}",
|
||||
"GO_DEFAULT={{user `go_default`}}"
|
||||
],
|
||||
"execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts":[
|
||||
|
||||
Reference in New Issue
Block a user