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).