release: update the kata-deploy yaml files accordingly

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 <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2021-09-20 14:06:15 +02:00
parent ea9b2f9c92
commit 43a72d76e2

View File

@ -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"