File tree 1 file changed +1
-26
lines changed
1 file changed +1
-26
lines changed Original file line number Diff line number Diff line change 17
17
url=" ${GITHUB_API_URL} /repos/${REPO} /releases?per_page=999"
18
18
releases=$( curl --silent --fail --location " ${authz[@]-} " " $url " )
19
19
versions=$( jq <<< " $releases" ' .[] | select(.prerelease==false) | .tag_name' )
20
-
21
- echo " ::group::All available K3s versions (unsorted)"
22
- echo " $versions "
23
- echo " ::endgroup::"
24
-
25
- # Sort the versions numerically, not lexographically:
26
- # 0. Preserve the original name of the version.
27
- # 1. Split the version nmame ("v1.19.4+k3s1") into parts (["1", "19", "4", "1"]).
28
- # 2. Convert parts to numbers when possible ([1, 19, 4, 1]).
29
- # 3. Sort numerically instead of lexographically.
30
- # 4. Restore the original name of each version.
31
- versions_sorted=$( jq --slurp <<< " $versions" '
32
- [ .[]
33
- | { original: .,
34
- numeric:
35
- .
36
- | ltrimstr("v")
37
- | split("(-|\\.|\\+k3s)"; "")
38
- | [ .[] | (tonumber? // .) ]
39
- }
40
- ]
41
- | sort_by(.numeric)
42
- | reverse
43
- | .[]
44
- | .original
45
- ' )
20
+ versions_sorted=$( sort <<< " $versions" --field-separator=- --key=1,1rV --key=2,2rV)
46
21
47
22
echo " ::group::All available K3s versions (newest on top)"
48
23
echo " $versions_sorted "
You can’t perform that action at this time.
0 commit comments