Skip to content

Commit 25b7059

Browse files
committed
Sort version numbers
Previously, the entries in https://golang.org/dl/?mode=json&include=all were already in descending order, but for some reason 1.17beta1 is showing up above 1.17rc1, so now we need to get a little more complicated.
1 parent 54aa949 commit 25b7059

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

versions.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,17 @@ for version in "${versions[@]}"; do
114114
export version
115115

116116
if \
117-
! goJson="$(jq <<<"$goVersions" -c '[ .[] | select(.major == env.version) ][0]')" \
117+
! goJson="$(jq <<<"$goVersions" -c '
118+
[ .[] | select(.major == env.version) ] | sort_by(
119+
.version
120+
| split(".")
121+
| map(
122+
if test("^[0-9]+$") then
123+
tonumber
124+
else . end
125+
)
126+
)[-1]
127+
')" \
118128
|| ! fullVersion="$(jq <<<"$goJson" -r '.version')" \
119129
|| [ -z "$fullVersion" ] \
120130
; then

0 commit comments

Comments
 (0)