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 <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2022-03-29 02:36:27 +00:00
parent 025fa60268
commit 93d03cc064

View File

@ -182,30 +182,22 @@ bump_repo() {
info "Updating kata-deploy / kata-cleanup image tags" info "Updating kata-deploy / kata-cleanup image tags"
local version_to_replace="${current_version}" local version_to_replace="${current_version}"
local replacement="${new_version}" local replacement="${new_version}"
local removed_files=false local need_commit=false
if [ "${target_branch}" == "main" ]; then if [ "${target_branch}" == "main" ];then
if [[ "${new_version}" =~ "rc" ]]; 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_deploy_stable_yaml}"
git rm "${kata_cleanup_stable_yaml}" git rm "${kata_cleanup_stable_yaml}"
removed_files=true need_commit=true
fi fi
elif [ "${new_version}" != *"rc"* ]; then
## these are the cases 1) and 2), where "alpha" and "rc0" are tagged as "latest" ## We are on a stable branch and creating new stable releases.
version_to_replace="latest" ## Need to change kata-deploy / kata-cleanup to use the stable tags.
replacement="latest" if [[ "${version_to_replace}" =~ "rc" ]]; then
else ## Coming from "rcX" so from the latest tag.
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.
version_to_replace="latest" version_to_replace="latest"
replacement="latest"
fi 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_deploy_yaml}"
sed -i "s#${registry}:${version_to_replace}#${registry}:${replacement}#g" "${kata_cleanup_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_deploy_yaml}"
git add "${kata_cleanup_yaml}" git add "${kata_cleanup_yaml}"
need_commit=true
fi
if [ "${need_commit}" == "true" ]; then
info "Creating the commit with the kata-deploy changes" info "Creating the commit with the kata-deploy changes"
local commit_msg="$(generate_kata_deploy_commit $new_version)" local commit_msg="$(generate_kata_deploy_commit $new_version)"
git commit -s -m "${commit_msg}" git commit -s -m "${commit_msg}"