diff --git a/.github/workflows/check-network.yaml b/.github/workflows/check-network.yaml index d2d6ff994f9a..3ca91d64889b 100644 --- a/.github/workflows/check-network.yaml +++ b/.github/workflows/check-network.yaml @@ -130,11 +130,6 @@ jobs: terraform apply -auto-approve - - name: Set k0sctl version - run: | - version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl) - echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV - - name: Create k0s Cluster using k0sctl id: k0sctl run: | diff --git a/.github/workflows/ostests-e2e.yaml b/.github/workflows/ostests-e2e.yaml index 1176c132729e..04a4d9577cd9 100644 --- a/.github/workflows/ostests-e2e.yaml +++ b/.github/workflows/ostests-e2e.yaml @@ -81,9 +81,15 @@ jobs: - name: "Workflow run :: Prepare" working-directory: ./ + env: + K0SCTL_VERSION: ${{ inputs.k0sctl-version }} run: | kubernetesVersion="$(./vars.sh kubernetes_version)" + k0sctlVersion="${K0SCTL_VERSION:-$(./vars.sh FROM=hack/tool k0sctl_version)}" + + set -x echo KUBERNETES_VERSION="$kubernetesVersion" >>"$GITHUB_ENV" + echo K0SCTL_VERSION="$k0sctlVersion" >>"$GITHUB_ENV" - name: "Terraform :: Requisites :: Download k0s" if: inputs.k0s-version == '' @@ -92,17 +98,6 @@ jobs: name: k0s-linux-amd64 path: ${{ github.workspace }}/.cache - - name: Set k0sctl version - run: | - if [ -z "${{ inputs.k0sctl-version }}" ]; then - version=$(grep k0sproject/k0sctl hack/tool/go.mod|cut -d" " -f2) - echo "Detected k0sctl dependency version ${version}" - else - version="${{ inputs.k0sctl-version }}" - echo "Using given k0sctl version ${version}" - fi - echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV - - name: "Terraform :: Requisites :: Prepare" env: K0S_VERSION: ${{ inputs.k0s-version }} diff --git a/.github/workflows/prepare-build-env.sh b/.github/workflows/prepare-build-env.sh index f109421c535f..2f04f4a8dfc9 100755 --- a/.github/workflows/prepare-build-env.sh +++ b/.github/workflows/prepare-build-env.sh @@ -3,18 +3,21 @@ set -eu goVersion="$(./vars.sh go_version)" +k0sctlVersion="$(./vars.sh FROM=hack/tool k0sctl_version)" golangciLintVersion="$(./vars.sh FROM=hack/tools golangci-lint_version)" pythonVersion="$(./vars.sh FROM=docs python_version)" cat <>"$GITHUB_ENV" GO_VERSION=$goVersion GOLANGCI_LINT_VERSION=$golangciLintVersion +K0SCTL_VERSION=$k0sctlVersion PYTHON_VERSION=$pythonVersion EOF -# shellcheck disable=SC1090 -. "$GITHUB_ENV" - echo ::group::OS Environment env | sort echo ::endgroup:: + +echo ::group::Build Environment +cat -- "$GITHUB_ENV" +echo ::endgroup:: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f435c989cc13..8e79c3f5d2b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -609,11 +609,6 @@ jobs: terraform apply -auto-approve - - name: Set k0sctl version - run: | - version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl) - echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV - - name: Create k0s Cluster using k0sctl id: k0sctl run: | diff --git a/vars.sh b/vars.sh index 28d189c32902..55db211e2e30 100755 --- a/vars.sh +++ b/vars.sh @@ -1,4 +1,5 @@ #!/usr/bin/env sh +#shellcheck disable=SC3043 set -eu @@ -12,6 +13,18 @@ print_usage() { echo " $0 FROM=docs python_version" } +version_from_go_mod() { + local pkg version rest + while read -r pkg version rest; do + if [ "$pkg" = "$1" ]; then + printf %s "$version" + return 0 + fi + done + + return 1 +} + fail() { echo "$@" >&2 print_usage >&2 @@ -41,6 +54,11 @@ 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 + exit 0 +fi + exec make --no-print-directory -r -s -f - <