From 43a72d76e2520ae044335b9f1dbf54c12363f54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 20 Sep 2021 14:06:15 +0200 Subject: [PATCH] release: update the kata-deploy yaml files accordingly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's teach our `update-repository-version.sh` script to properly update the kata-deploy tags on both kata-deploy and kata-cleanup yaml files. The 3 scenarios that we're dealing with, based on which branch we're targetting, are: ``` 1) [main] ------> [main] NO-OP "alpha0" "alpha1" +----------------+----------------+ | from | to | -----------------+----------------+----------------+ kata-deploy | "latest" | "latest" | -----------------+----------------+----------------+ kata-deploy-base | "stable | "stable" | -----------------+----------------+----------------+ 2) [main] ------> [stable] Update kata-deploy and "alpha2" "rc0" get rid of kata-deploy-base +----------------+----------------+ | from | to | -----------------+----------------+----------------+ kata-deploy | "latest" | "rc0" | -----------------+----------------+----------------+ kata-deploy-base | "stable" | REMOVED | -----------------+----------------+----------------+ 3) [stable] ------> [stable] Update kata-deploy "x.y.z" "x.y.(z+1)" +----------------+----------------+ | from | to | -----------------+----------------+----------------+ kata-deploy | "x.y.z" | "x.y.(z+1)" | -----------------+----------------+----------------+ kata-deploy-base | NON-EXISTENT | NON-EXISTENT | -----------------+----------------+----------------+ ``` And we can easily cover those 3 cases only with the information about the "${target_branch}" and the "${new_version}", where: * case 1) if "${target_branch}" is "main" *and* "${new_version}" contains "alpha", do nothing * case 2) if "${target_branch}" is "main" *and* "${new_version}" contains "rc": * change the kata-deploy & kata-cleanup tags from "latest" to "${new_version}". * delete the kata-deploy-stable & kata-cleanup-stable files. * case 3) if the "${target_branch}" contains "stable": * change the kata-deploy & kata-cleanup tags from "${current_version}" to "${new_version}". Signed-off-by: Fabiano FidĂȘncio --- .../release/update-repository-version.sh | 67 +++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/tools/packaging/release/update-repository-version.sh b/tools/packaging/release/update-repository-version.sh index d00c623a03..cded448cc0 100755 --- a/tools/packaging/release/update-repository-version.sh +++ b/tools/packaging/release/update-repository-version.sh @@ -111,13 +111,68 @@ bump_repo() { fi if [ "${repo}" == "kata-containers" ]; then - info "Updating kata-deploy / kata-cleanup image tags" - sed -i "s#quay.io/kata-containers/kata-deploy:${current_version}#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml - sed -i "s#quay.io/kata-containers/kata-deploy:${current_version}#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml - git diff + # Here there are 3 scenarios of what we can do, based on + # which branch we're targetting: + # + # 1) [main] ------> [main] NO-OP + # "alpha0" "alpha1" + # + # +----------------+----------------+ + # | from | to | + # -----------------+----------------+----------------+ + # kata-deploy | "latest" | "latest" | + # -----------------+----------------+----------------+ + # kata-deploy-base | "stable | "stable" | + # -----------------+----------------+----------------+ + # + # + # 2) [main] ------> [stable] Update kata-deploy and + # "alpha2" "rc0" get rid of kata-deploy-base + # + # +----------------+----------------+ + # | from | to | + # -----------------+----------------+----------------+ + # kata-deploy | "latest" | "rc0" | + # -----------------+----------------+----------------+ + # kata-deploy-base | "stable" | REMOVED | + # -----------------+----------------+----------------+ + # + # + # 3) [stable] ------> [stable] Update kata-deploy + # "x.y.z" "x.y.(z+1)" + # + # +----------------+----------------+ + # | from | to | + # -----------------+----------------+----------------+ + # kata-deploy | "x.y.z" | "x.y.(z+1)" | + # -----------------+----------------+----------------+ + # kata-deploy-base | NON-EXISTENT | NON-EXISTENT | + # -----------------+----------------+----------------+ - git add tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml - git add tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + info "Updating kata-deploy / kata-cleanup image tags" + if [ "${target_branch}" == "main" ] && [[ "${new_version}" =~ "rc" ]]; then + # case 2) + ## change the "latest" tag to the "#{new_version}" one + sed -i "s#quay.io/kata-containers/kata-deploy:latest#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml + sed -i "s#quay.io/kata-containers/kata-deploy:latest#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + + git diff + + git add tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml + git add tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + + ## and remove the kata-deploy & kata-cleanup stable yaml files + git rm tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml + git rm tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup-stable.yaml + elif [[ "${target_branch}" =~ "stable" ]]; then + # case 3) + sed -i "s#quay.io/kata-containers/kata-deploy:${current_version}#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml + sed -i "s#quay.io/kata-containers/kata-deploy:${current_version}#quay.io/kata-containers/kata-deploy:${new_version}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + git diff + + git add tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml + git add tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + fi fi info "Creating PR message"