Skip to content

Commit

Permalink
fix(ci): publishing dockerhub manifests (#3451)
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy authored Nov 28, 2023
1 parent 454e316 commit a59e7f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 16 additions & 8 deletions build-system/scripts/deploy_dockerhub
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand All @@ -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
Expand All @@ -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
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
4 changes: 1 addition & 3 deletions build-system/scripts/setup_env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a59e7f0

Please sign in to comment.