From fce201d4692d2c0faab27c397a2a93cce466e9d4 Mon Sep 17 00:00:00 2001 From: Knative Prow Robot Date: Thu, 2 Nov 2023 20:04:48 +0000 Subject: [PATCH] [release-1.11] add function to set latest semver to latest (#340) * add function to set latest semver to latest * Update release.sh Co-authored-by: Chris Suszynski * Update release.sh Co-authored-by: Chris Suszynski * Update release.sh --------- Co-authored-by: Krsna Mahapatra Co-authored-by: Chris Suszynski --- release.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/release.sh b/release.sh index 5d4f09a8..e6e386bb 100755 --- a/release.sh +++ b/release.sh @@ -655,6 +655,24 @@ function publish_artifacts() { banner "New release published successfully" } +# Sets the github release with the highest semver to 'latest' +function set_latest_to_highest_semver() { + 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 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'" +} + # Entry point for a release script. function main() { parse_flags "$@" @@ -727,6 +745,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).