Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function to set latest semver to latest #339

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,25 @@ 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)"
cardil marked this conversation as resolved.
Show resolved Hide resolved
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)"
cardil marked this conversation as resolved.
Show resolved Hide resolved
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)"
krsna-m marked this conversation as resolved.
Show resolved Hide resolved
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 +746,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