diff --git a/_scripts/latestver.py b/_scripts/latestver.py index d4138136..cad2f80a 100644 --- a/_scripts/latestver.py +++ b/_scripts/latestver.py @@ -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) diff --git a/_scripts/test_linux.sh b/_scripts/test_linux.sh index 2125af5f..a313c9e1 100755 --- a/_scripts/test_linux.sh +++ b/_scripts/test_linux.sh @@ -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 diff --git a/_scripts/test_windows.ps1 b/_scripts/test_windows.ps1 index 7d814b67..27c42751 100644 --- a/_scripts/test_windows.ps1 +++ b/_scripts/test_windows.ps1 @@ -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"