Skip to content

Commit

Permalink
Let the Autopilot matrix script fail when gh fails
Browse files Browse the repository at this point in the history
Use bash and pipefail for that. Also remove the usage for grep by
directly passing the filter value into the jq query.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
  • Loading branch information
twz123 committed Jun 21, 2023
1 parent 7d33b9a commit 356f780
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hack/tools/gen-matrix.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

# 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"]

set -e -o pipefail

list_k0s_releases() {
gh api -X GET /repos/k0sproject/k0s/releases \
-F per_page=100 --paginate \
--jq '.[] | select(.prerelease == false and .draft == false) | .name'
# shellcheck disable=SC2016
local query='.[] | select(.prerelease == false and .draft == false) | .name | select(startswith($ENV.VERSION_PREFIX))'
VERSION_PREFIX="v$1" gh api -X GET /repos/k0sproject/k0s/releases -F per_page=100 --paginate --jq "$query"
}

k0s_sort() {
go run github.com/k0sproject/version/cmd/k0s_sort@v0.2.2
}

latest_release() {
list_k0s_releases | grep -F "v$1" | k0s_sort | tail -1
list_k0s_releases "$1" | k0s_sort | tail -1
}

json_print_latest_releases() {
Expand Down

0 comments on commit 356f780

Please sign in to comment.