From ac958a3073b382a4fdfd8ddb8f6d2569303feb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 23 Nov 2021 10:36:20 +0100 Subject: [PATCH] tools: Use vars for the yaml files used in the update repo script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of always writing the full path of some files, let's just create some vars and avoid both repetition (which is quite error prone) and too long lines (which makes the file not so easy to read). Signed-off-by: Fabiano FidĂȘncio --- .../release/update-repository-version.sh | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/packaging/release/update-repository-version.sh b/tools/packaging/release/update-repository-version.sh index 2fec951d23..eddee58348 100755 --- a/tools/packaging/release/update-repository-version.sh +++ b/tools/packaging/release/update-repository-version.sh @@ -90,6 +90,14 @@ bump_repo() { pushd "${repo}" >>/dev/null + local kata_deploy_dir="tools/packaging/kata-deploy" + local kata_deploy_base="${kata_deploy_dir}/kata-deploy/base" + local kata_cleanup_base="${kata_deploy_dir}/kata-cleanup/base" + local kata_deploy_yaml="${kata_deploy_base}/kata-deploy.yaml" + local kata_cleanup_yaml="${kata_cleanup_base}/kata-cleanup.yaml" + local kata_deploy_stable_yaml="${kata_deploy_base}/kata-deploy-stable.yaml" + local kata_cleanup_stable_yaml="${kata_cleanup_base}/kata-cleanup-stable.yaml" + branch="${new_version}-branch-bump" git fetch origin "${target_branch}" git checkout "origin/${target_branch}" -b "${branch}" @@ -155,25 +163,25 @@ bump_repo() { 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 - 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 + git rm "${kata_deploy_stable_yaml}" + git rm "${kata_cleanup_stable_yaml}" + else ## this is the case 1) where we just do nothing replacement="latest" fi - version_to_replace="latest" fi if [ "${version_to_replace}" != "${replacement}" ]; then ## this covers case 2) and 3), as on both of them we have changes on kata-deploy / kata-cleanup files - sed -i "s#quay.io/kata-containers/kata-deploy:${version_to_replace}#quay.io/kata-containers/kata-deploy:${replacement}#g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml - sed -i "s#quay.io/kata-containers/kata-deploy:${version_to_replace}#quay.io/kata-containers/kata-deploy:${replacement}#g" tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml + sed -i "s#quay.io/kata-containers/kata-deploy:${version_to_replace}#quay.io/kata-containers/kata-deploy:${new_version}#g" "${kata_deploy_yaml}" + sed -i "s#quay.io/kata-containers/kata-deploy:${version_to_replace}#quay.io/kata-containers/kata-deploy:${new_version}#g" "${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 + git add "${kata_deploy_yaml}" + git add "${kata_cleanup_yaml}" fi fi