|
10 | 10 | # image as <image-tag>-arm64 |
11 | 11 | # |
12 | 12 | # The amd64 build and the arm64 leg run on separate native runners, so each |
13 | | -# pushes a single-platform image. For every ref <registry>/<repo>[:<t>]@A in |
| 13 | +# pushes a single-platform image. Built with SBOM=1 that image is an index of |
| 14 | +# itself and its attestation manifest, and the index made below carries both |
| 15 | +# attestations. For every ref <registry>/<repo>[:<t>]@A in |
14 | 16 | # the tree, whatever tag <t> it carries, with <tag> the <image-tag>: |
15 | 17 | # |
16 | 18 | # 1. B is the digest of <repo>:<tag>-arm64. No such image is not an error: |
@@ -109,10 +111,18 @@ manifest_digest() { |
109 | 111 | } |
110 | 112 |
|
111 | 113 | # image_arch <repo@digest> prints the architecture of a single-platform image, |
112 | | -# or nothing for an index or a non-image artifact. A registry error returns |
113 | | -# non-zero, like manifest_digest. |
| 114 | +# or nothing for an index of several platforms or a non-image artifact. An |
| 115 | +# image built with SBOM=1 is an index of one linux image and its attestation |
| 116 | +# manifest, and counts as that image. A registry error returns non-zero, like |
| 117 | +# manifest_digest. |
114 | 118 | image_arch() { |
115 | 119 | _ia_raw="$(sk inspect --raw "docker://$1")" || return 1 |
| 120 | + _ia_plat="$(printf '%s' "$_ia_raw" | jq -r ' |
| 121 | + if .manifests then |
| 122 | + [.manifests[] | select(.platform.os == "linux") | .platform.architecture] |
| 123 | + | if length == 1 then .[0] else empty end |
| 124 | + else empty end')" |
| 125 | + if [ -n "$_ia_plat" ]; then printf '%s\n' "$_ia_plat"; return 0; fi |
116 | 126 | printf '%s' "$_ia_raw" | jq -r '.config.mediaType // empty' \ |
117 | 127 | | grep -qE 'image\.config|container\.image' || return 0 |
118 | 128 | _ia_cfg="$(sk inspect --config "docker://$1")" || return 1 |
@@ -232,10 +242,15 @@ while read -r repo a reftags <&3; do |
232 | 242 | else |
233 | 243 | [ -n "$cur" ] || { echo "::error::${repo}:${tag} does not exist, though the tree pins it" >&2; exit 1; } |
234 | 244 | raw="$(sk inspect --raw "docker://${repo}@${cur}")" |
| 245 | + # An A built with SBOM=1 is itself an index, and the stitched one lists its |
| 246 | + # linux image rather than A. |
| 247 | + a_raw="$(sk inspect --raw "docker://${repo}@${a}")" |
| 248 | + a_members="$(printf '%s' "$a_raw" | jq -c --arg a "$a" \ |
| 249 | + 'if .manifests then [.manifests[] | select(.platform.os == "linux") | .digest] else [$a] end')" |
235 | 250 | # Its arm64 half need not be this run's B: a rerun rebuilds the arm64 |
236 | 251 | # image, which need not reproduce it byte for byte. |
237 | | - if ! printf '%s' "$raw" | jq -e --arg a "$a" \ |
238 | | - '(.manifests // []) as $m | any($m[]; .digest == $a) and any($m[]; .platform.architecture == "arm64")' >/dev/null; then |
| 252 | + if ! printf '%s' "$raw" | jq -e --argjson ms "$a_members" \ |
| 253 | + '(.manifests // []) as $m | ($ms | length) > 0 and all($ms[]; . as $d | any($m[]; .digest == $d)) and any($m[]; .platform.architecture == "arm64")' >/dev/null; then |
239 | 254 | echo "::error::${repo}:${tag} points at ${cur}, which is neither the digest the tree pins (${a}) nor an index of it and an arm64 image" >&2 |
240 | 255 | exit 1 |
241 | 256 | fi |
|
0 commit comments