From 6690223889d8a9c629fa1d8ebf3e0d6c9ba91645 Mon Sep 17 00:00:00 2001 From: Krsna Mahapatra Date: Thu, 2 Nov 2023 12:00:56 -0400 Subject: [PATCH 1/4] add function to set latest semver to latest --- release.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/release.sh b/release.sh index 5d4f09a8..933b66b3 100755 --- a/release.sh +++ b/release.sh @@ -655,6 +655,23 @@ function publish_artifacts() { banner "New release published successfully" } +# Sets the github release with the highest semver to 'latest' +function set_latest_to_highest_semver() { + # List latest release + local releases # don't combine with the line below, or $? will be 0 + # Support tags in two formats + # - knative-v1.0.0 + # - v1.0.0 + releases="$(hub_tool -p release | cut -d '-' -f2)" + [[ $? -eq 0 ]] || abort "cannot list releases" + local last_version="$(echo "${releases}" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r -V | head -1)" + local release_id # don't combine with the line below, or $? will be 0 + [[ $? -eq 0 ]] || abort "cannot get relase id from github" + release_id="$(hub_tool api /repos/${ORG_NAME}/${REPO_NAME}/releases/tags/knative-${last_version} | jq .id)" + hub_tool api --method PATCH /repos/knative/serving/releases/$release_id -F make_latest=true > /dev/null || abort "error settomg $last_version to 'latest'" + echo "Github release ${last_version} set as 'latest'" +} + # Entry point for a release script. function main() { parse_flags "$@" @@ -727,6 +744,7 @@ function main() { done echo "New release built successfully" publish_artifacts + set_latest_to_highest_semver } # Publishes a new release on GitHub, also git tagging it (unless this is not a versioned release). From 17e0747c8bc15f5bbe7140b420fb5120c863f8f1 Mon Sep 17 00:00:00 2001 From: kmahapatra Date: Thu, 2 Nov 2023 13:57:42 -0400 Subject: [PATCH 2/4] Update release.sh Co-authored-by: Chris Suszynski --- release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 933b66b3..465b01b1 100755 --- a/release.sh +++ b/release.sh @@ -663,7 +663,9 @@ function set_latest_to_highest_semver() { # - knative-v1.0.0 # - v1.0.0 releases="$(hub_tool -p release | cut -d '-' -f2)" - [[ $? -eq 0 ]] || abort "cannot list releases" + if ! [[ $? -eq 0 ]]; then + abort "cannot list releases" + fi local last_version="$(echo "${releases}" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r -V | head -1)" local release_id # don't combine with the line below, or $? will be 0 [[ $? -eq 0 ]] || abort "cannot get relase id from github" From c9a580febd5c1ca0cf674474ee41901040a6025f Mon Sep 17 00:00:00 2001 From: kmahapatra Date: Thu, 2 Nov 2023 13:58:37 -0400 Subject: [PATCH 3/4] Update release.sh Co-authored-by: Chris Suszynski --- release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 465b01b1..dd598d6d 100755 --- a/release.sh +++ b/release.sh @@ -668,8 +668,10 @@ function set_latest_to_highest_semver() { fi local last_version="$(echo "${releases}" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r -V | head -1)" local release_id # don't combine with the line below, or $? will be 0 - [[ $? -eq 0 ]] || abort "cannot get relase id from github" release_id="$(hub_tool api /repos/${ORG_NAME}/${REPO_NAME}/releases/tags/knative-${last_version} | jq .id)" + if [[ $? -ne 0 ]]; then + abort "cannot get relase id from github" + fi hub_tool api --method PATCH /repos/knative/serving/releases/$release_id -F make_latest=true > /dev/null || abort "error settomg $last_version to 'latest'" echo "Github release ${last_version} set as 'latest'" } From c07d6f996a68c925b5de7f29d13a929b2f470cfe Mon Sep 17 00:00:00 2001 From: kmahapatra Date: Thu, 2 Nov 2023 14:19:58 -0400 Subject: [PATCH 4/4] Update release.sh --- release.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/release.sh b/release.sh index dd598d6d..e6e386bb 100755 --- a/release.sh +++ b/release.sh @@ -657,21 +657,18 @@ function publish_artifacts() { # Sets the github release with the highest semver to 'latest' function set_latest_to_highest_semver() { - # List latest release - local releases # don't combine with the line below, or $? will be 0 - # Support tags in two formats - # - knative-v1.0.0 - # - v1.0.0 - releases="$(hub_tool -p release | cut -d '-' -f2)" + local last_version # don't combine with the line below, or $? will be 0 + last_version="$(hub_tool -p release | cut -d'-' -f2 | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$'| sort -r -V | head -1)" if ! [[ $? -eq 0 ]]; then abort "cannot list releases" fi - local last_version="$(echo "${releases}" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r -V | head -1)" + local release_id # don't combine with the line below, or $? will be 0 release_id="$(hub_tool api /repos/${ORG_NAME}/${REPO_NAME}/releases/tags/knative-${last_version} | jq .id)" if [[ $? -ne 0 ]]; then abort "cannot get relase id from github" fi + hub_tool api --method PATCH /repos/knative/serving/releases/$release_id -F make_latest=true > /dev/null || abort "error settomg $last_version to 'latest'" echo "Github release ${last_version} set as 'latest'" }