@@ -195,27 +195,44 @@ jobs:
195195 type=semver,pattern={{major}}
196196 - name : Create manifest list and push
197197 run : |
198- import os
199- import json
200- import subprocess
198+ set -Eeuo pipefail
199+
200+ CMD=(docker buildx imagetools create)
201201
202- CONTAINER = f"{os.getenv('FULLY_QUALIFIED_IMAGE_NAME')}"
203- METADATA = json.loads(os.getenv('METADATA_JSON'))
202+ # Build tag and annotation lists from metadata action output
203+ mapfile -t TAGS < <(jq -r '.tags[]? // empty' <<<"${METADATA_JSON}") || true
204+ mapfile -t ANNOTATIONS < <(jq -r '.annotations[]? // empty' <<<"${METADATA_JSON}") || true
204205
205- digests = [f for f in os.listdir('.') if f.startswith('sha256:') or len(f) == 64]
206+ for ann in "${ANNOTATIONS[@]:-}"; do
207+ [ -n "${ann}" ] && CMD+=( --annotation "${ann}" )
208+ done
209+ for tag in "${TAGS[@]:-}"; do
210+ [ -n "${tag}" ] && CMD+=( --tag "${tag}" )
211+ done
206212
207- command = ['docker', 'buildx', 'imagetools', 'create',
208- *[annotation for annotation in METADATA.get('annotations', []) for annotation in ('--annotation', annotation)],
209- *[tag for tag in METADATA.get('tags', []) for tag in ('--tag', tag)],
210- *[f"{CONTAINER}@sha256:{digest}" for digest in digests]
211- ]
213+ # Each file in the working directory represents a digest (either named sha256:<hash> or the 64-char digest itself)
214+ for f in *; do
215+ [ -f "$f" ] || continue
216+ digest=""
217+ if [[ "$f" == sha256:* ]]; then
218+ digest="${f#sha256:}"
219+ elif [[ ${#f} -eq 64 && "$f" =~ ^[a-f0-9]{64}$ ]]; then
220+ digest="$f"
221+ else
222+ continue
223+ fi
224+ CMD+=( "${CONTAINER}@sha256:${digest}" )
225+ done
212226
213- print(' '.join(command))
214- subprocess.run(command, check=True)
227+ echo "Creating manifest list with command:" >&2
228+ printf ' %q' "${CMD[@]}" >&2; echo >&2
229+
230+ # Execute the command
231+ "${CMD[@]}"
215232 env :
216- FULLY_QUALIFIED_IMAGE_NAME : ${{ needs.sanitize-image-name.outputs.fully-qualified-image-name }}
233+ CONTAINER : ${{ needs.sanitize-image-name.outputs.fully-qualified-image-name }}
217234 METADATA_JSON : ${{ steps.metadata.outputs.json }}
218- shell : python
235+ shell : bash
219236 working-directory : ${{ runner.temp }}/digests
220237 - name : Inspect manifest and extract digest
221238 id : inspect-manifest
0 commit comments