@@ -284,24 +284,34 @@ $(subst image_,push_image_,$(ALL_SUPPORTED_IMG_OS_ARCH)): image_$$(TARGETOS)_$$(
284284dist-image : $(ALL_SUPPORTED_IMG_OS_ARCH ) # # Build images for all supported platforms/architectures
285285
286286.PHONY : dist-image-push
287- # Generates a list of image references in the form of
288- # "$(IMAGE_REPO):$(IMAGE_TAG)-{platform}-{arch}" generated from a list of "image_{platform}_{arch}"
289- ALL_IMAGE_REFS = $( subst image-, $( IMAGE_REPO ) : $( IMAGE_TAG ) -, $(subst _,- ,$(ALL_SUPPORTED_IMG_OS_ARCH ) ) )
290- # Depends on "push_image_{platform}_{ arch}" targets
291- dist-image-push : dist-image $(subst image_,push_image_, $( ALL_SUPPORTED_IMG_OS_ARCH ) ) # # Push images and image manifest for all supported platforms
292- # Push all built images from the "image_{platform}_{arch}" target
293- @for img in $(ALL_IMAGE_REFS); do podman push $(PODMAN_OPTS) $$img; done
294- # If the manifest with the same tag exists we need to remove it first, otherwise
295- # podman manifest create fails
296- @2>/dev/null 1>/dev/null podman manifest rm $(IMAGE_REPO):$(IMAGE_TAG) || true
287+ ALL_IMAGE_REFS: = $( subst image-, $( IMAGE_REPO ) : $( IMAGE_TAG ) -, $( subst _,-, $( ALL_SUPPORTED_IMG_OS_ARCH ) ) )
288+
289+ dist- image-push : dist-image $(subst image_,push_image_ ,$(ALL_SUPPORTED_IMG_OS_ARCH ) ) # # Push images and multi-arch manifest
290+ @ # Push each single- arch image
291+ @for img in $(ALL_IMAGE_REFS ) ; do \
292+ podman push $( PODMAN_OPTS ) $$ img ; \
293+ done
294+
295+ @ # Recreate the manifest
296+ @podman manifest rm $(IMAGE_REPO):$(IMAGE_TAG) 2>/dev/null || true
297297 @podman manifest create $(IMAGE_REPO):$(IMAGE_TAG)
298- # We set the TARGETOS and TARGETARCH from the image reference, given the
299- # convention of having the image reference be tagged with "{tag}-{platform}-{arch}"
300- @for img in $(ALL_IMAGE_REFS); do TARGETOS=$$(echo $$img | sed -e 's/.*:[^-]\+-\([^-]\+\).*/\1/'); TARGETARCH=$${img/*-}; podman manifest add $(IMAGE_REPO):$(IMAGE_TAG) $(PODMAN_OPTS) $$img --os $${TARGETOS} --arch $${TARGETARCH}; done
298+
299+ @# Add each image with the correct os/arch
300+ @for img in $(ALL_IMAGE_REFS); do \
301+ TAG=$${img# #*:}; \
302+ TARGETOS=$$(echo "$$TAG" | rev | cut -d- -f2 | rev); \
303+ TARGETARCH=$$(echo "$$TAG" | rev | cut -d- -f1 | rev); \
304+ podman manifest add $(IMAGE_REPO):$(IMAGE_TAG) $(PODMAN_OPTS) "$$img" \
305+ --os "$$TARGETOS" --arch "$$TARGETARCH"; \
306+ done
307+
308+ @# Push the manifest
301309 @podman manifest push $(IMAGE_REPO):$(IMAGE_TAG) $(IMAGE_REPO):$(IMAGE_TAG)
310+
302311ifdef ADD_IMAGE_TAG
303- @for tag in $(ADD_IMAGE_TAG); do
304- @podman manifest push $(IMAGE_REPO):$(IMAGE_TAG) $(IMAGE_REPO):$${tag}
312+ @# Also push any additional tags (like “snapshot”)
313+ @for tag in $(ADD_IMAGE_TAG); do \
314+ podman manifest push $(IMAGE_REPO):$(IMAGE_TAG) $(IMAGE_REPO):$$tag; \
305315 done
306316endif
307317
0 commit comments