attach-arm64: address review (never roll back a newer publish, mandatory --expect-index, --follow-tag, trunk-only, pin checks to planned amd64 digest)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-19 21:11:26 -08:00
1 parent 02de5c6568
commit 42f72e24ff
3 files changed
+120 -22

No files matched your search

+11 -3
View File
@@ -3,7 +3,7 @@ run-name: attach arm64 to ${{ github.event.inputs.image }}:php${{ github.event.i
# Manual only (never on push): publishes an arm64 image for an EXISTING tag of cac or cac-fpm
# and merges it with the tag's CURRENT amd64 manifest into a new index. The amd64 image is
# NOT rebuilt and NOT touched: its manifest digest (and config, layers, attestation) stay
# byte-identical; only the tag's index digest changes. Use it to restore an arm64 entry that a
# byte-identical (with force=true the old arm64 is replaced and the amd64 attestation entry is not carried); only the tag's index digest changes. Use it to restore an arm64 entry that a
# later amd64-only publish dropped (the arm64 leg of build-push.yaml is best effort).
#
# One leg per run (image + phpver), and runs are serialised (concurrency group below), because
@@ -33,6 +33,8 @@ concurrency:
jobs:
Attach-arm64:
# Only from trunk: the arm64 is built from the dispatched ref's Dockerfile.
if: github.ref == 'refs/heads/trunk'
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
@@ -179,12 +181,14 @@ jobs:
TAG: ${{ steps.v.outputs.tag }}
BINS: ${{ steps.v.outputs.bins }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
AMD64: ${{ steps.plan.outputs.amd64 }}
run: |
set -euo pipefail
[[ "$AMD64" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no planned amd64 digest"; exit 1; }
[[ "$ARM64_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no arm64 digest from the build"; exit 1; }
bins=(); for b in $BINS; do bins+=(--bin "$b"); done
python3 -I scripts/verify-image-arch.py --image "$REPO@$ARM64_DIGEST" --platform linux/arm64 "${bins[@]}"
python3 -I scripts/verify-image-arch.py --image "$REPO:$TAG" --platform linux/amd64 "${bins[@]}"
python3 -I scripts/verify-image-arch.py --image "$REPO@$AMD64" --platform linux/amd64 "${bins[@]}"
# The new arm64 was built now, the amd64 entry earlier: refuse a PHP version skew between them.
- name: PHP version parity (amd64 native, arm64 under QEMU)
@@ -192,9 +196,10 @@ jobs:
REPO: ${{ steps.v.outputs.repo }}
TAG: ${{ steps.v.outputs.tag }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
AMD64: ${{ steps.plan.outputs.amd64 }}
run: |
set -euo pipefail
want=$(docker run --rm --platform linux/amd64 --entrypoint php "$REPO:$TAG" -r 'echo PHP_VERSION;')
want=$(docker run --rm --platform linux/amd64 --entrypoint php "$REPO@$AMD64" -r 'echo PHP_VERSION;')
got=$(docker run --rm --platform linux/arm64 --entrypoint php "$REPO@$ARM64_DIGEST" -r 'echo PHP_VERSION;')
echo "amd64 (existing tag) PHP ${want}; new arm64 PHP ${got}"
[[ "$want" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || { echo "::error::cannot read the amd64 PHP version"; exit 1; }
@@ -211,7 +216,10 @@ jobs:
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
run: |
set -euo pipefail
[[ "$BEFORE" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no plan digest"; exit 1; }
f=(); [ "$FORCE" = true ] && f=(--force)
# :latest tracks php85 in the normal build; keep that alias equal if (and only if) it is one.
[ "$TAG" = php85 ] && f+=(--follow-tag latest)
scripts/attach-arm64-index.sh --repo "$REPO" --tag "$TAG" \
--arm64 "$ARM64_DIGEST" --expect-index "$BEFORE" "${f[@]}"
docker buildx imagetools inspect "$REPO:$TAG"