TeamCity: prefer go rc builds over beta (#2619)

Works around https://github.com/golang/go/issues/47367.
This commit is contained in:
nd 2021-07-24 20:14:45 +02:00 committed by GitHub
parent aaed14ffcb
commit 150ef04177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

@ -2,10 +2,12 @@
import json
import urllib
import sys
from distutils.version import LooseVersion
ver = sys.argv[1]
d = json.loads(urllib.urlopen('https://golang.org/dl/?mode=json&include=all').read())
for x in d:
ds = sorted(d, reverse=True, key=lambda it: LooseVersion(it['version'][2:]))
for x in ds:
if x['version'][:len(ver)] == ver:
print x['version']
exit(0)

@ -31,7 +31,7 @@ if [ "$version" = "gotip" ]; then
cd -
else
echo Finding latest patch version for $version
version=$(curl 'https://golang.org/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|beta|rc)' | head -1)
version=$(curl 'https://golang.org/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|beta|rc)' | sort -rV | head -1)
echo "Go $version on $arch"
getgo $version
fi

@ -50,9 +50,16 @@ if ($version -eq "gotip") {
} else {
# Install Go
Write-Host "Finding latest patch version for $version"
$version = Invoke-WebRequest -Uri 'https://golang.org/dl/?mode=json&include=all' -UseBasicParsing | foreach {$_.Content} | ConvertFrom-Json | foreach {$_.version} | Select-String -Pattern "^$version($|\.|beta|rc)" | Select-Object -First 1 | foreach {$_.Line}
Write-Host "Go $version on $arch"
GetGo $version
$versions = Invoke-WebRequest -Uri 'https://golang.org/dl/?mode=json&include=all' -UseBasicParsing | foreach {$_.Content} | ConvertFrom-Json
$v = $versions | foreach {$_.version} | Select-String -Pattern "^$version($|\.)" | Sort-Object -Descending | Select-Object -First 1
if ($v -eq $null) {
$v = $versions | foreach {$_.version} | Select-String -Pattern "^$version(rc)" | Sort-Object -Descending | Select-Object -First 1
}
if ($v -eq $null) {
$v = $versions | foreach {$_.version} | Select-String -Pattern "^$version(beta)" | Sort-Object -Descending | Select-Object -First 1
}
Write-Host "Go $v on $arch"
GetGo $v
}
$env:GOPATH = "C:\gopath"