diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 29664e59182b..f34c53d27728 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -54,6 +54,12 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + k0sSortVersion=$(./vars.sh FROM=. k0s_sort_version) + mkdir -p build/cache/bin + curl -sSLo build/cache/bin/k0s_sort --retry 5 --retry-all-errors "https://github.com/k0sproject/version/releases/download/$k0sSortVersion/k0s_sort-linux-amd64" + chmod +x build/cache/bin/k0s_sort + export PATH="$(realpath build/cache/bin):$PATH" + set -x k8sVersion="$(./vars.sh kubernetes_version)" majorVersion="${k8sVersion%%.*}" diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index ce6a756bec50..12ca18e162d6 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -27,17 +27,16 @@ jobs: cache: pip cache-dependency-path: docs/requirements.txt - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - - name: Install dependencies run: | pip install --disable-pip-version-check -r docs/requirements_pip.txt pip --version pip install --disable-pip-version-check -r docs/requirements.txt - go install github.com/k0sproject/version/cmd/k0s_sort@v0.4.2 + + mkdir -p build/cache/bin + curl -sSLo build/cache/bin/k0s_sort --retry 5 --retry-all-errors "https://github.com/k0sproject/version/releases/download/$K0S_SORT_VERSION/k0s_sort-linux-amd64" + chmod +x build/cache/bin/k0s_sort + printf '%s\n' "$(realpath build/cache/bin)" >>"$GITHUB_PATH" - name: Generate docs env: diff --git a/hack/tools/gen-matrix.sh b/hack/tools/gen-matrix.sh index 534fa4a159e8..95a09925dc3f 100755 --- a/hack/tools/gen-matrix.sh +++ b/hack/tools/gen-matrix.sh @@ -5,7 +5,7 @@ # ./gen-matrix.sh 1.24.2 1.24.3 # Output: ["v1.24.2+k0s.0", "v1.24.3+k0s.0"] -set -e -o pipefail +set -euo pipefail list_k0s_releases() { # shellcheck disable=SC2016 @@ -13,12 +13,8 @@ list_k0s_releases() { 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.4.2 -} - latest_release() { - list_k0s_releases "$1" | k0s_sort | tail -1 + list_k0s_releases "$1" | k0s_sort -l } json_print_latest_releases() { diff --git a/hack/tools/run-autopilot-matrix-tests.sh b/hack/tools/run-autopilot-matrix-tests.sh index 6060d52e454c..2c458e939ce7 100755 --- a/hack/tools/run-autopilot-matrix-tests.sh +++ b/hack/tools/run-autopilot-matrix-tests.sh @@ -10,11 +10,8 @@ TESTS=${1:-check-ap-ha3x3} VERSIONS="$2" ARCH=${TARGET_ARCH:-amd64} -go install github.com/k0sproject/version/cmd/k0s_sort@v0.4.2 -GOBIN="$(go env GOPATH)/bin" - if [[ -z "$VERSIONS" ]]; then - RELEASE=$(gh release list -L 100 -R k0sproject/k0s | grep "+k0s." | grep -v Draft | cut -f 1 | $GOBIN/k0s_sort | tail -1) + RELEASE=$(gh release list -L 100 -R k0sproject/k0s | grep "+k0s." | grep -v Draft | cut -f 1 | k0s_sort -l) VERSIONS=$RELEASE fi diff --git a/vars.sh b/vars.sh index 55db211e2e30..240a3158fbb8 100755 --- a/vars.sh +++ b/vars.sh @@ -54,8 +54,14 @@ done [ -n "$var" ] || fail Makefile variable not given [ -n "$from" ] || from=embedded-bins -if [ "$var" = k0sctl_version ]; then - version_from_go_mod github.com/k0sproject/k0sctl <"$from"/go.mod +case "$var" in +k0sctl_version) pkg=github.com/k0sproject/k0sctl ;; +k0s_sort_version) pkg=github.com/k0sproject/version ;; +*) pkg='' ;; +esac + +if [ -n "$pkg" ]; then + version_from_go_mod "$pkg" <"$from"/go.mod exit 0 fi