From 435214fcd6a2719571e98898453c1e7632cac220 Mon Sep 17 00:00:00 2001 From: jcope Date: Wed, 17 Nov 2021 18:15:01 -0600 Subject: [PATCH 1/4] add AIO release behavior --- Makefile | 5 +++++ scripts/release.sh | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Makefile b/Makefile index 4e22d97504..423e958b47 100644 --- a/Makefile +++ b/Makefile @@ -180,6 +180,11 @@ build-containerized-cross-build: +$(MAKE) build-containerized-cross-build-linux-arm64 .PHONY: build-containerized-cross-build +build-containerized-all-in-one-cross-build: + +$(MAKE) build-containerized-all-in-one-amd64 + +$(MAKE) build-containerized-all-in-one-arm64 +.PHONY build-containerized-all-in-one-cross-build + build-containerized-all-in-one-amd64: +$(MAKE) _build_containerized_aio ARCH=amd64 .PHONY: build-containerized-all-in-one diff --git a/scripts/release.sh b/scripts/release.sh index 7c227c8865..2f575ad618 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -144,6 +144,13 @@ stage_release_image_binaries() { echo "$dest" } +build_aio_container_images_artifacts() { + ( + cd "$ROOT" + make build-containerized-all-in-one-cross-build SOURCE_GIT_TAG="$VERSION" IMAGE_REPO="$AIO_IMAGE_REPO" + ) || return 1 +} + build_container_images_artifacts() { ( cd "$ROOT" @@ -151,6 +158,12 @@ build_container_images_artifacts() { ) || return 1 } +push_aio_container_image_artifacts() { + for t in "${AIO_RELEASE_IMAGE_TAGS[@]}"; do + podman push "$t" + done +} + push_container_image_artifacts() { for t in "${RELEASE_IMAGE_TAGS[@]}"; do podman push "$t" @@ -237,12 +250,15 @@ QUAY_OWNER=${QUAY_OWNER:="microshift"} API_DATA="$(generate_api_release_request "true")" # leave body empty for now IMAGE_REPO="quay.io/$QUAY_OWNER/microshift" +AIO_IMAGE_REPO="quai.io/$QUAY_OWNER/microsift-aio" RELEASE_IMAGE_TAGS=("$IMAGE_REPO:$VERSION-linux-amd64" "$IMAGE_REPO:$VERSION-linux-arm64" ) +AIO_RELEASE_IMAGE_TAGS=("$AIO_IMAGE_REPO:$VERSION-linux-amd64" "$AIO_IMAGE_REPO:$VERSION-linux-arm64" ) STAGING_DIR="$ROOT/_output/staging" mkdir -p "$STAGING_DIR" build_container_images_artifacts || exit 1 +build_aio_container_images_artifacts || exit 1 STAGE_DIR=$(stage_release_image_binaries) || exit 1 push_container_image_artifacts || exit 1 push_container_manifest || exit 1 From 7147f3fc88bcc65393c393d06ca3074733b1470d Mon Sep 17 00:00:00 2001 From: jcope Date: Thu, 18 Nov 2021 13:44:58 -0600 Subject: [PATCH 2/4] e2e test run --- Makefile | 2 +- scripts/release.sh | 61 +++++++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 423e958b47..1c305a5456 100644 --- a/Makefile +++ b/Makefile @@ -183,7 +183,7 @@ build-containerized-cross-build: build-containerized-all-in-one-cross-build: +$(MAKE) build-containerized-all-in-one-amd64 +$(MAKE) build-containerized-all-in-one-arm64 -.PHONY build-containerized-all-in-one-cross-build +.PHONY: build-containerized-all-in-one-cross-build build-containerized-all-in-one-amd64: +$(MAKE) _build_containerized_aio ARCH=amd64 diff --git a/scripts/release.sh b/scripts/release.sh index 2f575ad618..6664903f9f 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -21,6 +21,8 @@ # quay.io/microshift/microshift. A github release and a tag are created and identified with the version generated # by the Makefile. Cross-compiled binaries are copied from the container images and published in the git release. +set -x + set -euo pipefail shopt -s expand_aliases @@ -35,8 +37,8 @@ ROOT="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/../")" # Check for a container manager cli (podman || docker), and alias it to "podman", since # they implement the same cli interface. -__ctr_mgr_alias=$({ which podman &>/dev/null && echo "podman"; } || { which docker &>/dev/null && echo "docker"; } || echo "") -alias podman=${__ctr_mgr_alias:?"a container manager (podman || docker) is required as part of the release automation; none found"} +__ctr_cli_alias=$({ which podman &>/dev/null && echo "podman"; } || { which docker &>/dev/null && echo "docker"; } || echo "") +alias podman=${__ctr_cli_alias:?"a container manager (podman || docker) is required as part of the release automation; none found"} ######### # FUNCS # @@ -171,35 +173,41 @@ push_container_image_artifacts() { } podman_create_manifest(){ - podman manifest create "$IMAGE_REPO:$VERSION" >&2 - for ref in "${RELEASE_IMAGE_TAGS[@]}"; do - podman manifest add "$IMAGE_REPO:$VERSION" "docker://$ref" + local dest_repo="$1" + local image_tags="$2" + podman manifest create "$dest_repo:$VERSION" >&2 + for ref in "${image_tags[@]}"; do + podman manifest add "$dest_repo:$VERSION" "docker://$ref" done - podman manifest push "$IMAGE_REPO:$VERSION" "$IMAGE_REPO:$VERSION" - podman manifest push "$IMAGE_REPO:$VERSION" "$IMAGE_REPO:latest" + podman manifest push "$dest_repo:$VERSION" "$dest_repo:$VERSION" + podman manifest push "$dest_repo:$VERSION" "$dest_repo:latest" } docker_create_manifest(){ - local amend_images_options - for image in "${RELEASE_IMAGE_TAGS[@]}"; do - amend_images_options+="--amend $image" - done + local dest_repo="$1" + local image_tags="$2" # use docker cli directly for clarity, as this is a docker-only func - docker manifest create "$IMAGE_REPO:$VERSION" "${RELEASE_IMAGE_TAGS[@]}" >&2 - docker tag "$IMAGE_REPO:$VERSION" "$IMAGE_REPO:latest" - docker manifest push "$IMAGE_REPO:$VERSION" - docker manifest push "$IMAGE_REPO:latest" + docker manifest create "$dest_repo:$VERSION" "${image_tags[@]}" >&2 + docker tag "$dest_repo:$VERSION" "$dest_repo:latest" + docker manifest push "$dest_repo:$VERSION" + docker manifest push "$dest_repo:latest" } +# It is necessarry to differentiate between podman and docker manifest create subcommands. +# Podman exepcts the manifest to exist prior to adding images; docker allows for an image list +# to be passed at creation. Podman also requires a prefixed "container-transport", which is +# no recognized by docker, causing the command to fail. push_container_manifest() { + local images_tags="$1" + local dest_repo="$2" local cli="$(alias podman)" if [[ "${cli#*=}" =~ docker ]]; then docker_create_manifest else podman_create_manifest fi - } + debug() { local version="$1" local api_request="$2" @@ -257,10 +265,17 @@ AIO_RELEASE_IMAGE_TAGS=("$AIO_IMAGE_REPO:$VERSION-linux-amd64" "$AIO_IMAGE_REPO: STAGING_DIR="$ROOT/_output/staging" mkdir -p "$STAGING_DIR" -build_container_images_artifacts || exit 1 -build_aio_container_images_artifacts || exit 1 -STAGE_DIR=$(stage_release_image_binaries) || exit 1 -push_container_image_artifacts || exit 1 -push_container_manifest || exit 1 -UPLOAD_URL="$(git_create_release "$API_DATA" "$TOKEN")" || exit 1 -git_post_artifacts "$STAGE_DIR" "$UPLOAD_URL" "$TOKEN" || exit 1 +# publish containerized microshift +build_container_images_artifacts || exit 1 +STAGE_DIR=$(stage_release_image_binaries) || exit 1 +push_container_image_artifacts || exit 1 +push_container_manifest "$IMAGE_REPO" "${RELEASE_IMAGE_TAGS[@]}" || exit 1 + +# publish binaries +UPLOAD_URL="$(git_create_release "$API_DATA" "$TOKEN")" || exit 1 +git_post_artifacts "$STAGE_DIR" "$UPLOAD_URL" "$TOKEN" || exit 1 + +# publish aio container +build_aio_container_images_artifacts || exit 1 +push_aio_container_image_artifacts || exit 1 +push_container_manifest "$AIO_IMAGE_REPO" "${AIO_RELEASE_IMAGE_TAGS[@]}" || exit 1 From 5afcc51992fb76a4b7285416cdeec1675cadc17a Mon Sep 17 00:00:00 2001 From: Jon Cope Date: Fri, 19 Nov 2021 09:19:11 -0600 Subject: [PATCH 3/4] tweak value passing --- scripts/release.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 6664903f9f..d823ee756f 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -176,7 +176,7 @@ podman_create_manifest(){ local dest_repo="$1" local image_tags="$2" podman manifest create "$dest_repo:$VERSION" >&2 - for ref in "${image_tags[@]}"; do + for ref in "${image_tags[*]}"; do podman manifest add "$dest_repo:$VERSION" "docker://$ref" done podman manifest push "$dest_repo:$VERSION" "$dest_repo:$VERSION" @@ -187,7 +187,7 @@ docker_create_manifest(){ local dest_repo="$1" local image_tags="$2" # use docker cli directly for clarity, as this is a docker-only func - docker manifest create "$dest_repo:$VERSION" "${image_tags[@]}" >&2 + docker manifest create "$dest_repo:$VERSION" "${image_tags[*]}" >&2 docker tag "$dest_repo:$VERSION" "$dest_repo:latest" docker manifest push "$dest_repo:$VERSION" docker manifest push "$dest_repo:latest" @@ -198,13 +198,13 @@ docker_create_manifest(){ # to be passed at creation. Podman also requires a prefixed "container-transport", which is # no recognized by docker, causing the command to fail. push_container_manifest() { - local images_tags="$1" - local dest_repo="$2" + local dest_repo="$1" + local image_tags="$2" local cli="$(alias podman)" if [[ "${cli#*=}" =~ docker ]]; then - docker_create_manifest + docker_create_manifest "$dest_repo" "$image_tags[*]" else - podman_create_manifest + podman_create_manifest "$dest_repo" "$image_tags[*]" fi } From a4990964b7065a0dcc2f74e68b7a6527b6b07ae2 Mon Sep 17 00:00:00 2001 From: Jon Cope Date: Fri, 19 Nov 2021 16:14:53 -0600 Subject: [PATCH 4/4] typo --- scripts/release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index d823ee756f..db9049e73b 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -149,7 +149,7 @@ stage_release_image_binaries() { build_aio_container_images_artifacts() { ( cd "$ROOT" - make build-containerized-all-in-one-cross-build SOURCE_GIT_TAG="$VERSION" IMAGE_REPO="$AIO_IMAGE_REPO" + make build-containerized-all-in-one-cross-build SOURCE_GIT_TAG="$VERSION" IMAGE_REPO_AIO="$AIO_IMAGE_REPO" ) || return 1 } @@ -258,7 +258,7 @@ QUAY_OWNER=${QUAY_OWNER:="microshift"} API_DATA="$(generate_api_release_request "true")" # leave body empty for now IMAGE_REPO="quay.io/$QUAY_OWNER/microshift" -AIO_IMAGE_REPO="quai.io/$QUAY_OWNER/microsift-aio" +AIO_IMAGE_REPO="quay.io/$QUAY_OWNER/microshift-aio" RELEASE_IMAGE_TAGS=("$IMAGE_REPO:$VERSION-linux-amd64" "$IMAGE_REPO:$VERSION-linux-arm64" ) AIO_RELEASE_IMAGE_TAGS=("$AIO_IMAGE_REPO:$VERSION-linux-amd64" "$AIO_IMAGE_REPO:$VERSION-linux-arm64" )