Skip to content

Commit

Permalink
Pick up k0s_sort version from go.mod in CI
Browse files Browse the repository at this point in the history
The GitHub runners ship with _some_ go toolchain installed by default.
This will be enough to figure out the k0s_sort version from go.mod.

Download and use the newly available pre-built binary instead compiling
it on the fly.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Jan 11, 2024
1 parent b30c5e4 commit a7aa090
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
k0sSortVersion="$(go list -m -f '{{.Version}}' github.com/k0sproject/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"
export PATH="$(realpath build/cache/bin):$PATH"
k8sVersion="$(./vars.sh kubernetes_version)"
majorVersion="${k8sVersion%%.*}"
minorVersion=${k8sVersion#$majorVersion.}
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]
k0sSortVersion="$(go list -m -f '{{.Version}}' github.com/k0sproject/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"
echo PATH="$(realpath build/cache/bin):$PATH" >>"$GITHUB_ENV"
- 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

0 comments on commit a7aa090

Please sign in to comment.