Skip to content

Commit

Permalink
add function to set latest semver to latest (#339)
Browse files Browse the repository at this point in the history
* add function to set latest semver to latest

* Update release.sh

Co-authored-by: Chris Suszynski <[email protected]>

* Update release.sh

Co-authored-by: Chris Suszynski <[email protected]>

* Update release.sh

---------

Co-authored-by: Chris Suszynski <[email protected]>
  • Loading branch information
krsna-m and cardil authored Nov 2, 2023
1 parent d4af42e commit 0d99b7e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 0d99b7e

Please sign in to comment.