From dee1bd6691126b764f6ce0c93dc15e2d4bc459a7 Mon Sep 17 00:00:00 2001 From: David Simansky Date: Thu, 29 Feb 2024 12:47:22 +0100 Subject: [PATCH] chore: Refactor cluster allocation script to use latest Knative bits --- hack/allocate.sh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/hack/allocate.sh b/hack/allocate.sh index 665dcf265..81a82d097 100755 --- a/hack/allocate.sh +++ b/hack/allocate.sh @@ -25,9 +25,9 @@ export TERM="${TERM:-dumb}" main() { - local knative_serving_version=v1.13.0 - local knative_eventing_version=v1.13.0 - local contour_version=v1.13.0 + local knative_serving_version="v$(get_latest_release_version "knative" "serving")" + local knative_eventing_version="v$(get_latest_release_version "knative" "eventing")" + local contour_version="v$(get_latest_release_version "knative-extensions" "net-contour")" # Kubernetes Version node image per Kind releases (full hash is suggested): # https://github.com/kubernetes-sigs/kind/releases @@ -56,6 +56,34 @@ main() { echo "${em}DONE${me}" } +# Returns whether the current branch is a release branch. +function is_release_branch() { + [[ $(current_branch) =~ ^release-[0-9\.]+$ ]] +} + +# Retrieve latest version from given Knative repository tags +# On 'main' branch the latest released version is returned +# On 'release-x.y' branch the latest patch version for 'x.y.*' is returned +# Similar to hack/library.sh get_latest_knative_yaml_source() +function get_latest_release_version() { + local org_name="$1" + local repo_name="$2" + local major_minor="" + if is_release_branch; then + local branch_name + branch_name="$(current_branch)" + major_minor="${branch_name##release-}" + fi + local version + version="$(git ls-remote --tags --ref https://github.com/"${org_name}"/"${repo_name}".git \ + | grep "${major_minor}" \ + | cut -d '-' -f2 \ + | cut -d 'v' -f2 \ + | sort -Vr \ + | head -n 1)" + echo "${version}" +} + kubernetes() { echo "${em}① Kubernetes${me}" cat <