Skip to content

Commit 20034e0

Browse files
Tag builder latest by the digest of the full manifest list
pack pushes an image per target under the version tag before it pushes the manifest list there, and the registry can still return one of those right after the push. On builder-noble-java-tiny 0.0.200, `crane tag <version> latest` copied the linux/arm64 image to `latest`, so amd64 builds failed with "exec format error" (paketo-buildpacks/builder-noble-java-tiny#344). Read the version tag until it lists every target of builder.toml (fail after a minute), then tag latest by the digest of exactly that manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0883456 commit 20034e0

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎builder/.github/workflows/push-image.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,23 @@ jobs:
9191
./scripts/publish.sh --builder-toml-path "${{ matrix.builders.path }}/builder.toml" \
9292
--builder-image-ref "${IMAGE_REF}"
9393
94-
./.bin/crane tag "${IMAGE_REF}" latest
94+
EXPECTED_PLATFORMS=$(grep -c '^\[\[targets\]\]' "${{ matrix.builders.path }}/builder.toml" || true)
95+
if [ "${EXPECTED_PLATFORMS}" -eq 0 ]; then
96+
EXPECTED_PLATFORMS=1
97+
fi
98+
99+
MAX_ATTEMPTS=12
100+
for _ in $(seq 1 "${MAX_ATTEMPTS}"); do
101+
./.bin/crane manifest "${IMAGE_REF}" > manifest.json
102+
PLATFORMS=$(jq 'if .manifests then (.manifests | length) else 1 end' manifest.json)
103+
if [ "${PLATFORMS}" -eq "${EXPECTED_PLATFORMS}" ]; then
104+
./.bin/crane tag "${DOCKERHUB_ORG}/${CONTAINER_REPO}@sha256:$(sha256sum manifest.json | cut -d ' ' -f 1)" latest
105+
exit 0
106+
fi
107+
sleep 5
108+
done
109+
echo "::error::${IMAGE_REF} has ${PLATFORMS} platforms, expected ${EXPECTED_PLATFORMS}"
110+
exit 1
95111
96112
failure:
97113
name: Alert on Failure

0 commit comments

Comments
 (0)