Skip to content

Commit

Permalink
Merge pull request #3922 from twz123/k0s-sort-version-in-ci
Browse files Browse the repository at this point in the history
Pick up k0s_sort version from go.mod in CI
  • Loading branch information
twz123 authored Jan 17, 2024
2 parents f2f1b0d + 87601dc commit 2d7683e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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%%.*}"
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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:
Expand Down
8 changes: 2 additions & 6 deletions hack/tools/gen-matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
# ./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
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/[email protected]
}

latest_release() {
list_k0s_releases "$1" | k0s_sort | tail -1
list_k0s_releases "$1" | k0s_sort -l
}

json_print_latest_releases() {
Expand Down
5 changes: 1 addition & 4 deletions hack/tools/run-autopilot-matrix-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ TESTS=${1:-check-ap-ha3x3}
VERSIONS="$2"
ARCH=${TARGET_ARCH:-amd64}

go install github.com/k0sproject/version/cmd/[email protected]
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

Expand Down
10 changes: 8 additions & 2 deletions vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2d7683e

Please sign in to comment.