From a59e7f020e80916e501811c762876c36692742fc Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 28 Nov 2023 20:25:16 +0000 Subject: [PATCH] fix(ci): publishing dockerhub manifests (#3451) --- build-system/scripts/deploy_dockerhub | 24 ++++++++++++++++-------- build-system/scripts/setup_env | 4 +--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/build-system/scripts/deploy_dockerhub b/build-system/scripts/deploy_dockerhub index 06d0933d430..4009f453d48 100755 --- a/build-system/scripts/deploy_dockerhub +++ b/build-system/scripts/deploy_dockerhub @@ -6,8 +6,11 @@ REPOSITORY=$1 # TODO: Why even provide this? We can just figure it out by probing. ARCH_LIST=${2:-} +# The tag to use for release images. Can be turned into an argument if needed, for now we only release 'latest'. +DIST_TAG="latest" + function docker_or_dryrun { - if [ "$DRY_DEPLOY" -eq 1 ] ; then + if [ "$DRY_DEPLOY" -eq 1 ]; then echo DRY RUN: docker $@ else retry docker $@ @@ -18,7 +21,9 @@ echo "Repo: $REPOSITORY" echo "Arch List: $ARCH_LIST" VERSION_TAG=$(extract_tag_version $REPOSITORY true) -MANIFEST_DEPLOY_URI=aztecprotocol/$REPOSITORY:$VERSION_TAG + +MANIFEST_DEPLOY_URI=$DOCKERHUB_ACCOUNT/$REPOSITORY:$VERSION_TAG +MANIFEST_DIST_URI=$DOCKERHUB_ACCOUNT/$REPOSITORY:$DIST_TAG # Login to dockerhub and ecr dockerhub_login @@ -30,16 +35,19 @@ for ARCH in $ARCH_LIST; do retry docker pull $IMAGE_COMMIT_URI # Retag and push image. - IMAGE_DEPLOY_URI=aztecprotocol/$REPOSITORY:$VERSION_TAG-$ARCH + IMAGE_DEPLOY_URI=$DOCKERHUB_ACCOUNT/$REPOSITORY:$VERSION_TAG-$ARCH docker tag $IMAGE_COMMIT_URI $IMAGE_DEPLOY_URI docker_or_dryrun push $IMAGE_DEPLOY_URI echo "Adding image $IMAGE_DEPLOY_URI to manifest list $MANIFEST_DEPLOY_URI..." docker_or_dryrun manifest create $MANIFEST_DEPLOY_URI --amend $IMAGE_DEPLOY_URI -done -docker_or_dryrun push $MANIFEST_DEPLOY_URI + echo "Adding image $IMAGE_DEPLOY_URI to manifest list $MANIFEST_DIST_URI" + docker_or_dryrun manifest create $MANIFEST_DIST_URI --amend $IMAGE_DEPLOY_URI +done -# Retag versioned as latest. -docker_or_dryrun tag $MANIFEST_DEPLOY_URI aztecprotocol/$REPOSITORY:latest -docker_or_dryrun push aztecprotocol/$REPOSITORY:latest \ No newline at end of file +echo "Tagging $MANIFEST_DEPLOY_URI as $VERSION_TAG..." +docker_or_dryrun manifest push --purge $MANIFEST_DEPLOY_URI +# Publish version as latest. +echo "Tagging $MANIFEST_DEPLOY_URI as $DIST_TAG..." +docker_or_dryrun manifest push --purge $MANIFEST_DIST_URI diff --git a/build-system/scripts/setup_env b/build-system/scripts/setup_env index 33887ab9b5d..5127936d346 100755 --- a/build-system/scripts/setup_env +++ b/build-system/scripts/setup_env @@ -31,8 +31,6 @@ echo "PULL_REQUEST=$PULL_REQUEST" if [[ "$COMMIT_MESSAGE" == *"[ci dry-deploy]"* ]]; then COMMIT_TAG=v999.999.999 DRY_DEPLOY=1 -else - DRY_DEPLOY=0 fi if [ -n "${COMMIT_TAG:-}" ]; then @@ -83,7 +81,7 @@ echo export DEPLOY_ENV=$DEPLOY_ENV >> $BASH_ENV echo export DEPLOY_TAG=$DEPLOY_TAG >> $BASH_ENV echo export BRANCH=$BRANCH >> $BASH_ENV echo export PULL_REQUEST=$PULL_REQUEST >> $BASH_ENV -echo export DRY_DEPLOY=${DRY_DEPLOY:-} >> $BASH_ENV +echo export DRY_DEPLOY=${DRY_DEPLOY:-0} >> $BASH_ENV # We want very strict failures on any failing command, undefined variable, or commands that pipe to other commands. echo set -euo pipefail >> $BASH_ENV # Enable logging if [ci debug] is in commit message.