Skip to content

Commit ea92eba

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 serve 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 ea92eba

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,29 @@ 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+
# pack pushes an image per target under IMAGE_REF before the manifest list, and the registry
95+
# can still serve one of them right after the push. Tag latest by the digest of a manifest
96+
# that lists every target of builder.toml, so it never ends up single-platform.
97+
EXPECTED=$(grep -c '^\[\[targets\]\]' "${{ matrix.builders.path }}/builder.toml" || true)
98+
if [ "${EXPECTED}" -lt 1 ]; then
99+
EXPECTED=1
100+
fi
101+
102+
for attempt in $(seq 1 12); do
103+
./.bin/crane manifest "${IMAGE_REF}" > manifest.json
104+
PLATFORMS=$(jq 'if .manifests then [.manifests[] | select(.platform.architecture != "unknown")] | length else 1 end' manifest.json)
105+
if [ "${PLATFORMS}" -eq "${EXPECTED}" ]; then
106+
break
107+
fi
108+
if [ "${attempt}" -eq 12 ]; then
109+
echo "::error::${IMAGE_REF} lists ${PLATFORMS} platforms, builder.toml has ${EXPECTED} targets"
110+
exit 1
111+
fi
112+
sleep 5
113+
done
114+
115+
DIGEST="sha256:$(sha256sum manifest.json | cut -d ' ' -f 1)"
116+
./.bin/crane tag "${DOCKERHUB_ORG}/${CONTAINER_REPO}@${DIGEST}" latest
95117
96118
failure:
97119
name: Alert on Failure

0 commit comments

Comments
 (0)