From cc965fa0cb2304d9c99457439f252974b1455d68 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Tue, 29 Mar 2022 02:36:27 +0000 Subject: [PATCH] kata-deploy: fix version bump from -rc to stable In such case, we should bump from "latest" tag rather than from current_version. Fixes: #3986 Signed-off-by: Peng Tao --- .../release/update-repository-version.sh | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/tools/packaging/release/update-repository-version.sh b/tools/packaging/release/update-repository-version.sh index 9dc1b3cc46..79b674db6f 100755 --- a/tools/packaging/release/update-repository-version.sh +++ b/tools/packaging/release/update-repository-version.sh @@ -182,30 +182,22 @@ bump_repo() { info "Updating kata-deploy / kata-cleanup image tags" local version_to_replace="${current_version}" local replacement="${new_version}" - local removed_files=false - if [ "${target_branch}" == "main" ]; then + local need_commit=false + if [ "${target_branch}" == "main" ];then if [[ "${new_version}" =~ "rc" ]]; then - ## this is the case 2) where we remove te kata-deploy / kata-cleanup stable files + ## We are bumping from alpha to RC, should drop kata-deploy-stable yamls. git rm "${kata_deploy_stable_yaml}" git rm "${kata_cleanup_stable_yaml}" - removed_files=true + need_commit=true fi - - ## these are the cases 1) and 2), where "alpha" and "rc0" are tagged as "latest" - version_to_replace="latest" - replacement="latest" - else - if [[ "${new_version}" =~ "rc" ]]; then - ## we're in a stable branch, coming from "rcX" (tagged as latest) and we're going - ## to "rcX+1", which should still be tagged as latest. + elif [ "${new_version}" != *"rc"* ]; then + ## We are on a stable branch and creating new stable releases. + ## Need to change kata-deploy / kata-cleanup to use the stable tags. + if [[ "${version_to_replace}" =~ "rc" ]]; then + ## Coming from "rcX" so from the latest tag. version_to_replace="latest" - replacement="latest" fi - fi - - if [ "${version_to_replace}" != "${replacement}" ] || [ "${removed_files}" == "true" ]; then - ## this covers case 3), as it has changes on kata-deploy / kata-cleanup files sed -i "s#${registry}:${version_to_replace}#${registry}:${replacement}#g" "${kata_deploy_yaml}" sed -i "s#${registry}:${version_to_replace}#${registry}:${replacement}#g" "${kata_cleanup_yaml}" @@ -214,6 +206,10 @@ bump_repo() { git add "${kata_deploy_yaml}" git add "${kata_cleanup_yaml}" + need_commit=true + fi + + if [ "${need_commit}" == "true" ]; then info "Creating the commit with the kata-deploy changes" local commit_msg="$(generate_kata_deploy_commit $new_version)" git commit -s -m "${commit_msg}"