From 13db8a3b38628e5fe6553ef910ca587d225ac611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Suszy=C5=84ski?= Date: Thu, 9 Nov 2023 19:26:13 +0100 Subject: [PATCH 1/2] Don't set latest release when not publishing to GH --- release.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 68e75e9c..2dce0915 100755 --- a/release.sh +++ b/release.sh @@ -658,13 +658,18 @@ function publish_artifacts() { # 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 + if ! (( PUBLISH_TO_GITHUB )); then + return 0 + fi + echo "Setting latest release to highest semver" + + local last_version release_id + 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" @@ -701,6 +706,8 @@ function main() { function_exists build_release || abort "function 'build_release()' not defined" [[ -x ${VALIDATION_TESTS} ]] || abort "test script '${VALIDATION_TESTS}' doesn't exist" + banner "Environment variables" + env # Log what will be done and where. banner "Release configuration" if which gcloud &>/dev/null ; then From f32df65702981f81de34a302043c79f6ef8d37ec Mon Sep 17 00:00:00 2001 From: Chris Suszynski Date: Thu, 9 Nov 2023 19:46:45 +0100 Subject: [PATCH 2/2] Add explanation Co-authored-by: kmahapatra --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 2dce0915..256ae40d 100755 --- a/release.sh +++ b/release.sh @@ -663,7 +663,7 @@ function set_latest_to_highest_semver() { fi echo "Setting latest release to highest semver" - local last_version release_id + local last_version release_id # don't combine with assignment else $? 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