From b07c81bfc9b7ece530ce49846cb3a42f7a6b6374 Mon Sep 17 00:00:00 2001 From: William Bezuidenhout Date: Thu, 2 May 2024 10:16:58 +0200 Subject: [PATCH] release: handle more registries for promotion (#62269) * release: handle more registries for promotion * shellcheck * review comments --- dev/ci/internal/ci/images_operations.go | 2 +- dev/ci/internal/ci/release_operations.go | 2 +- dev/ci/push_all.sh | 6 +++--- tools/release/promote_images.sh | 22 ++++++++++++++-------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dev/ci/internal/ci/images_operations.go b/dev/ci/internal/ci/images_operations.go index 4a37dbf2360..f3c07f98264 100644 --- a/dev/ci/internal/ci/images_operations.go +++ b/dev/ci/internal/ci/images_operations.go @@ -125,7 +125,7 @@ func bazelPushImagesCmd(c Config, isCandidate bool, opts ...bk.StepOpt) func(*bk bk.Env("CLOUD_EPHEMERAL", cloudEphemeral), bk.Env("DEV_REGISTRY", devRegistry), bk.Env("PROD_REGISTRY", prodRegistry), - bk.Env("ADDITIONAL_PROD_REGISTRY", additionalProdRegistry), + bk.Env("ADDITIONAL_PROD_REGISTRIES", additionalProdRegistry), bk.Cmd(bazelStampedCmd(fmt.Sprintf(`build $$(bazel --bazelrc=%s --bazelrc=.aspect/bazelrc/ci.sourcegraph.bazelrc query 'kind("oci_push rule", //...)')`, bazelRC))), bk.ArtifactPaths("build_event_log.bin"), bk.AnnotatedCmd( diff --git a/dev/ci/internal/ci/release_operations.go b/dev/ci/internal/ci/release_operations.go index d1b85d9eed6..1ba2e7400e2 100644 --- a/dev/ci/internal/ci/release_operations.go +++ b/dev/ci/internal/ci/release_operations.go @@ -21,7 +21,7 @@ func releasePromoteImages(c Config) operations.Operation { bk.Env("VERSION", c.Version), bk.Env("INTERNAL_REGISTRY", images.SourcegraphInternalReleaseRegistry), bk.Env("PUBLIC_REGISTRY", images.SourcegraphDockerPublishRegistry), - bk.Env("ADDITIONAL_PROD_REGISTRY", images.SourcegraphArtifactRegistryPublicRegistry), + bk.Env("ADDITIONAL_PROD_REGISTRIES", images.SourcegraphArtifactRegistryPublicRegistry), bk.AnnotatedCmd( fmt.Sprintf("./tools/release/promote_images.sh %s", image_args), bk.AnnotatedCmdOpts{ diff --git a/dev/ci/push_all.sh b/dev/ci/push_all.sh index d560c99e0d5..12ee0adb6ca 100755 --- a/dev/ci/push_all.sh +++ b/dev/ci/push_all.sh @@ -76,9 +76,9 @@ prod_registries=( "$PROD_REGISTRY" ) -additional_prod_registry=${ADDITIONAL_PROD_REGISTRY:-""} -if [ -n "$additional_prod_registry" ]; then - prod_registries+=("$additional_prod_registry") +if [ -n "${ADDITIONAL_PROD_REGISTRIES}" ]; then + IFS=' ' read -r -a registries <<< "$ADDITIONAL_PROD_REGISTRIES" + prod_registries+=("${registries[@]}") fi date_fragment="$(date +%Y-%m-%d)" diff --git a/tools/release/promote_images.sh b/tools/release/promote_images.sh index a80214d2e97..f4ce592a24b 100755 --- a/tools/release/promote_images.sh +++ b/tools/release/promote_images.sh @@ -12,6 +12,12 @@ if [ "$#" -lt 1 ]; then exit 1 fi +# We're transitioning to GAR because of DockerHub new rate limiting affecting GCP +# See https://github.com/sourcegraph/sourcegraph/issues/61696 +# Set IFS to space and read into an array +IFS=' ' read -r -a PROMOTION_REGISTRIES <<< "$ADDITIONAL_PROD_REGISTRIES" +PROMOTION_REGISTRIES=("$PUBLIC_REGISTRY" "${PROMOTION_REGISTRIES[@]}" ) + echo -e "## Release: image promotions" > ./annotations/image_promotions.md echo -e "\n| Name | From | To |\n|---|---|---|" >> ./annotations/image_promotions.md for name in "${@:1}"; do @@ -21,13 +27,13 @@ for name in "${@:1}"; do docker pull "${INTERNAL_REGISTRY}/${name}:${VERSION}" # Push it on the classic public registry (DockerHub) - docker tag "${INTERNAL_REGISTRY}/${name}:${VERSION}" "${PUBLIC_REGISTRY}/${name}:${VERSION}" - docker push "${PUBLIC_REGISTRY}/${name}:${VERSION}" + pushed="" + for registry in "${PROMOTION_REGISTRIES[@]}"; do + target="${registry}/${name}:${VERSION}" + docker tag "${INTERNAL_REGISTRY}/${name}:${VERSION}" "$target" + docker push "$target" + pushed="$pushed \`$target\`" + done - # We're transitioning to GAR because of DockerHub new rate limiting affecting GCP - # See https://github.com/sourcegraph/sourcegraph/issues/61696 - docker tag "${INTERNAL_REGISTRY}/${name}:${VERSION}" "${ADDITIONAL_PROD_REGISTRY}/${name}:${VERSION}" - docker push "${ADDITIONAL_PROD_REGISTRY}/${name}:${VERSION}" - - echo -e "| ${name} | \`${INTERNAL_REGISTRY}/${name}:${VERSION}\` | \`${PUBLIC_REGISTRY}/${name}:${VERSION}\` \`${ADDITIONAL_PROD_REGISTRY}/${name}:${VERSION}\` |" >>./annotations/image_promotions.md + echo -e "| ${name} | \`${INTERNAL_REGISTRY}/${name}:${VERSION}\` | ${pushed} |" >>./annotations/image_promotions.md done