forked from k0sproject/k0s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test Autopilot updates for current and previous k0s minor versions
Currently, Autopilot update tests are hard-coded to use some 1.24 k0s versions. Use the current Kubernetes version to determine the latest k0s releases for that minor version and the previous minor version. Use these k0s versions as a base for the Autopilot update tests. Signed-off-by: Tom Wieczorek <[email protected]> (cherry picked from commit 8b365f1)
- Loading branch information
1 parent
fb7514a
commit 446b691
Showing
2 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env sh | ||
|
||
# Founds the last k0s releases of the given versions and generates json MATRIX_OUTPUT for github actions. | ||
# Finds the last k0s releases of the given versions and generates json MATRIX_OUTPUT for github actions. | ||
# Usage: | ||
# ./gen-matrix.sh 1.24.2 1.24.3 | ||
# Output: ["v1.24.2+k0s.0","v1.24.3+k0s.0"] | ||
# Output: ["v1.24.2+k0s.0", "v1.24.3+k0s.0"] | ||
|
||
go install github.com/k0sproject/version/cmd/[email protected] | ||
GOBIN="$(go env GOPATH)/bin" | ||
MATRIX_OUTPUT="[" | ||
COMMA="" | ||
for i in "$@"; do \ | ||
RELEASE=$(gh release list -L 100 -R k0sproject/k0s | grep "+k0s." | grep -v Draft | cut -f 1 | $GOBIN/k0s_sort | grep $i | tail -1) | ||
MATRIX_OUTPUT+="$COMMA\"$RELEASE\"" | ||
COMMA="," | ||
done | ||
list_k0s_releases() { | ||
gh api -X GET /repos/k0sproject/k0s/releases \ | ||
-F per_page=100 --paginate \ | ||
--jq '.[] | select(.prerelease == false and .draft == false) | .name' | ||
} | ||
|
||
MATRIX_OUTPUT+="]" | ||
k0s_sort() { | ||
go run github.com/k0sproject/version/cmd/[email protected] | ||
} | ||
|
||
echo $MATRIX_OUTPUT | ||
latest_release() { | ||
list_k0s_releases | grep -F "v$1" | k0s_sort | tail -1 | ||
} | ||
|
||
json_print_latest_releases() { | ||
printf '[' | ||
|
||
pattern='"%s"' | ||
for i in "$@"; do | ||
latestRelease="$(latest_release "$i")" | ||
[ -z "$latestRelease" ] || { | ||
# shellcheck disable=SC2059 | ||
printf "$pattern" "$latestRelease" | ||
pattern=', "%s"' | ||
} | ||
done | ||
|
||
echo ']' | ||
} | ||
|
||
json_print_latest_releases "$@" |