release: Add _publish_multiarch_manifest()

This function, as it names says, will be used to publish multiarch
manifests for the Kata Containers CI and Kata Containers releases.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2024-02-23 17:54:03 +01:00
parent fb2ef32c04
commit a45988766c
No known key found for this signature in database
GPG Key ID: EE926C2BDACC177B
3 changed files with 43 additions and 29 deletions

View File

@ -103,9 +103,7 @@ jobs:
- name: Push multi-arch manifest
run: |
docker manifest create quay.io/kata-containers/kata-deploy-ci:kata-containers-latest \
--amend quay.io/kata-containers/kata-deploy-ci:kata-containers-amd64 \
--amend quay.io/kata-containers/kata-deploy-ci:kata-containers-arm64 \
--amend quay.io/kata-containers/kata-deploy-ci:kata-containers-s390x \
--amend quay.io/kata-containers/kata-deploy-ci:kata-containers-ppc64le
docker manifest push quay.io/kata-containers/kata-deploy-ci:kata-containers-latest
./tools/packaging/release/release.sh publish-multiarch-manifest
env:
KATA_DEPLOY_IMAGE_TAGS="kata-containers-latest"
KATA_DEPLOY_REGISTRIES="quay.io/kata-containers/kata-deploy-ci"

View File

@ -55,27 +55,13 @@ jobs:
- name: Push multi-arch manifest
run: |
# tag the container image we created and push to DockerHub
tag=$(echo $GITHUB_REF | cut -d/ -f3-)
tags=($tag)
tags+=($([[ "$tag" =~ "alpha"|"rc" ]] && echo "latest" || echo "stable"))
# push to quay.io and docker.io
for tag in ${tags[@]}; do
docker manifest create quay.io/kata-containers/kata-deploy:${tag} \
--amend quay.io/kata-containers/kata-deploy:${tag}-amd64 \
--amend quay.io/kata-containers/kata-deploy:${tag}-arm64 \
--amend quay.io/kata-containers/kata-deploy:${tag}-s390x \
--amend quay.io/kata-containers/kata-deploy:${tag}-ppc64le
tags="$(echo $GITHUB_REF | cut -d/ -f3-)"
tags+=" $([[ \"${tag}\" =~ \"alpha\"|\"rc\" ]] && echo \"latest\" || echo \"stable\"))"
echo "KATA_DEPLOY_IMAGE_TAGS=\"${tags}\"" >> "$GITHUB_ENV"
docker manifest create docker.io/katadocker/kata-deploy:${tag} \
--amend docker.io/katadocker/kata-deploy:${tag}-amd64 \
--amend docker.io/katadocker/kata-deploy:${tag}-arm64 \
--amend docker.io/katadocker/kata-deploy:${tag}-s390x \
--amend docker.io/katadocker/kata-deploy:${tag}-ppc64le
docker manifest push quay.io/kata-containers/kata-deploy:${tag}
docker manifest push docker.io/katadocker/kata-deploy:${tag}
done
./tools/packaging/release/release.sh publish-multiarch-manifest
env:
KATA_DEPLOY_REGISTRIES: "quay.io/kata-containers/kata-deploy docker.io/katadocker/kata-deploy"
upload-multi-arch-static-tarball:
needs: publish-multi-arch-images

View File

@ -15,23 +15,53 @@ set -o errtrace
this_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root_dir="$(cd "$this_script_dir/../../../" && pwd)"
IFS=' ' read -a IMAGE_TAGS <<< "${KATA_DEPLOY_IMAGE_TAGS:-}"
IFS=' ' read -a REGISTRIES <<< "${KATA_DEPLOY_REGISTRIES:-}"
function _die()
{
echo >&2 "ERROR: $*"
exit 1
}
function _info()
function _check_required_env_var()
{
echo "INFO: $*"
local env_var
case ${1} in
KATA_DEPLOY_IMAGE_TAGS) env_var="${KATA_DEPLOY_IMAGE_TAGS}" ;;
KATA_DEPLOY_REGISTRIES) env_var="${KATA_DEPLOY_REGISTRIES}" ;;
*) >&2 _die "Invalid environment variable \"${1}\"" ;;
esac
[ -z "${env_var}" ] && \
_die "\"${1}\" environment variable is required but was not set"
}
function _publish_multiarch_manifest()
{
_check_required_env_var "KATA_DEPLOY_IMAGE_TAGS"
_check_required_env_var "KATA_DEPLOY_REGISTRIES"
for registry in ${REGISTRIES[@]}; do
for tag in ${IMAGE_TAGS[@]}; do
docker manifest create ${registry}:${tag} \
--amend ${registry}:${tag}-amd64 \
--amend ${registry}:${tag}-arm64 \
--amend ${registry}:${tag}-s390x \
--amend ${registry}:${tag}-ppc64le
docker manifest push ${registry}:${tag}
done
done
}
function main()
{
action="${1:-}"
_info "DO NOT USE this script, it does nothing!"
case "${action}" in
publish-multiarch-manifest) _publish_multiarch_manifest ;;
*) >&2 _die "Invalid argument" ;;
esac
}