Skip to content

Commit

Permalink
Tools: New Docker release tagging script (#2989)
Browse files Browse the repository at this point in the history
* Tools: New Docker release tagging script

* Fix typo
  • Loading branch information
pglombardo authored Jan 16, 2025
1 parent bcb683d commit d4bfc52
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/docker-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: Docker Container Builds
on:
push:
tags:
- "stable"
- "v*.*.*"

workflow_dispatch:
Expand Down
49 changes: 49 additions & 0 deletions bin/move_up_stable_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Ensure the script exits on errors
set -e

# Check for input arguments
if [ "$#" -ne 1 ]; then
echo "Usage: ./move_up_stable_tag.sh <target-tag-without-v>"
exit 1
fi

SOURCE_TAG="$1"
ALIAS_TAG="stable"

# List of images to retag
IMAGES=(
"pglombardo/pwpush"
"pglombardo/pwpush-worker"
"pglombardo/pwpush-public-gateway"
)

for IMAGE in "${IMAGES[@]}"; do
echo "Retrieving digests for ${IMAGE}:${SOURCE_TAG}..."

# Use docker manifest inspect to parse platform-specific digests
MANIFEST_JSON=$(docker manifest inspect "${IMAGE}:${SOURCE_TAG}")

AMD64_DIGEST=$(echo "${MANIFEST_JSON}" | jq -r '.manifests[] | select(.platform.architecture == "amd64") | .digest')
ARM64_DIGEST=$(echo "${MANIFEST_JSON}" | jq -r '.manifests[] | select(.platform.architecture == "arm64") | .digest')

if [ -z "${AMD64_DIGEST}" ] || [ -z "${ARM64_DIGEST}" ]; then
echo "Error: Could not retrieve digests for ${IMAGE}:${SOURCE_TAG}"
exit 1
fi

echo "Creating manifest for ${IMAGE}:${ALIAS_TAG}..."
docker manifest create "${IMAGE}:${ALIAS_TAG}" \
--amend "${IMAGE}@${AMD64_DIGEST}" \
--amend "${IMAGE}@${ARM64_DIGEST}"

echo "Annotating platforms for ${IMAGE}:${ALIAS_TAG}..."
docker manifest annotate "${IMAGE}:${ALIAS_TAG}" "${IMAGE}@${AMD64_DIGEST}" --arch amd64
docker manifest annotate "${IMAGE}:${ALIAS_TAG}" "${IMAGE}@${ARM64_DIGEST}" --arch arm64

echo "Pushing manifest for ${IMAGE}:${ALIAS_TAG}..."
docker manifest push "${IMAGE}:${ALIAS_TAG}"
done

echo "All images have been tagged as '${ALIAS_TAG}' successfully."

0 comments on commit d4bfc52

Please sign in to comment.