0ecf51dc26
A floating tag silently substitutes the image under consumers who did not ask for a new one — the same hazard already avoided by pinning the pre-commit step. Alias only :<version> onto the default distro's build. Drop the :latest references from the README, distro.env and check-distros.
44 lines
1.7 KiB
Bash
Executable File
44 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Every distros/<name>/ needs a complete distro.env and an entry in every Woodpecker
|
|
# matrix, or a newly added distro silently never gets built.
|
|
set -uo pipefail
|
|
|
|
KEYS="BASE_IMAGE_NAME IMAGE TAG_SUFFIX DEFAULT ESTATE_REPO PACKAGES GO_MIN"
|
|
WORKFLOWS=(.woodpecker/build.yaml .woodpecker/docker.yaml)
|
|
|
|
fail=0
|
|
for d in distros/*/; do
|
|
n=$(basename "$d")
|
|
for k in $KEYS; do
|
|
grep -q "^${k}=" "${d}distro.env" || { echo "${d}distro.env: missing ${k}"; fail=1; }
|
|
done
|
|
for wf in "${WORKFLOWS[@]}"; do
|
|
grep -q "DISTRO: ${n}\$" "$wf" || { echo "${wf}: distro ${n} missing from matrix"; fail=1; }
|
|
|
|
# A matrix entry that restates a distro.env key must not drift from it — a stale
|
|
# BASE_IMAGE here silently overrides distro.env for every CI build.
|
|
while IFS='=' read -r k v; do
|
|
[ -n "$k" ] || continue
|
|
grep -q "^${k}=" "${d}distro.env" || continue
|
|
ev=$(sed -n "s/^${k}=//p" "${d}distro.env" | head -1 | sed 's/^"//;s/"$//')
|
|
[ "$v" = "$ev" ] || { echo "${wf}: matrix ${k}=\"${v}\" for ${n} disagrees with ${d}distro.env (\"${ev}\")"; fail=1; }
|
|
done <<EOF
|
|
$(awk -v d="$n" '
|
|
$0 ~ "^[[:space:]]*-[[:space:]]+DISTRO:[[:space:]]*"d"[[:space:]]*$" { inb=1; next }
|
|
inb && /^[[:space:]]*-/ { inb=0 }
|
|
inb && match($0, /^[[:space:]]+[A-Z_]+:/) {
|
|
k=$1; sub(/:$/,"",k)
|
|
v=$0; sub(/^[[:space:]]*[A-Z_]+:[[:space:]]*/,"",v); gsub(/^"|"$/,"",v)
|
|
print k "=" v
|
|
}
|
|
' "$wf")
|
|
EOF
|
|
done
|
|
done
|
|
|
|
# Exactly one distro owns the unsuffixed :<version> tag.
|
|
defaults=$(grep -l 'DEFAULT="true"' distros/*/distro.env | wc -l)
|
|
[ "$defaults" -eq 1 ] || { echo "expected exactly one distro with DEFAULT=\"true\", found ${defaults}"; fail=1; }
|
|
|
|
exit "$fail"
|