mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 08:31:53 -05:00
2.4.0 and 2.5.0 shipped no standalone binaries, and nothing could add them afterwards: re-running a release uses the tag's own workflow and pushes the images again. Run by hand from main with a tag, release.yml now builds the binaries that release lacks, or the ones named, from the tag's source, and attaches them signed and attested as a tag run does. It first verifies the release's sha256sums.txt against its cosign bundle and the attached binaries against that file, then rewrites it to cover every binary. A backfill never pushes or signs images and never creates a release; tag runs build and publish as before. Refs #8715
55 lines
2.7 KiB
Bash
Executable File
55 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Writes <dist>/sha256sums.txt for a release: the binaries staged in <dist> plus every binary the
|
|
# release already carries (downloaded into <existing>) that <dist> does not replace.
|
|
#
|
|
# release-binaries-sums.sh <existing> <dist>
|
|
#
|
|
# The release's current sha256sums.txt is first verified against its cosign bundle, signed by
|
|
# release.yml as docs/getting-started/installation.md tells users to check it, and the existing
|
|
# binaries are then checked against that file. So a backfill never vouches for a file the release
|
|
# did not already sign: a sums file without a bundle that verifies, or an existing binary that is
|
|
# missing from it or does not match it, stops the publish. With nothing in <existing> (a tag
|
|
# run) the result is plain `sha256sum floci-aws-*` over <dist>, as before.
|
|
set -euo pipefail
|
|
|
|
EXISTING=${1:?usage: release-binaries-sums.sh <existing> <dist>}
|
|
DIST=${2:?usage: release-binaries-sums.sh <existing> <dist>}
|
|
|
|
binaries() {
|
|
find "$1" -maxdepth 1 -type f -name 'floci-aws-*' ! -name '*.sigstore.json' -exec basename {} \; | sort
|
|
}
|
|
|
|
existing=$(binaries "$EXISTING")
|
|
lines=()
|
|
if [ -n "$existing" ]; then
|
|
if [ ! -f "$EXISTING/sha256sums.txt" ]; then
|
|
echo "::error::the release has binaries but no sha256sums.txt; it cannot be extended safely" >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -f "$EXISTING/sha256sums.txt.sigstore.json" ]; then
|
|
echo "::error::the release's sha256sums.txt has no cosign bundle; it cannot be extended safely" >&2
|
|
exit 1
|
|
fi
|
|
cosign verify-blob "$EXISTING/sha256sums.txt" --bundle "$EXISTING/sha256sums.txt.sigstore.json" \
|
|
--certificate-identity-regexp '^https://github.com/floci-io/floci/.github/workflows/release.yml@' \
|
|
--certificate-oidc-issuer https://token.actions.githubusercontent.com >&2 \
|
|
|| { echo "::error::the release's sha256sums.txt does not verify against its cosign bundle" >&2; exit 1; }
|
|
while IFS= read -r name; do
|
|
grep -qE "^[0-9a-f]{64} $name\$" "$EXISTING/sha256sums.txt" \
|
|
|| { echo "::error::$name is attached but not listed in the release's sha256sums.txt" >&2; exit 1; }
|
|
done <<< "$existing"
|
|
(cd "$EXISTING" && sha256sum --ignore-missing -c sha256sums.txt) >&2
|
|
while IFS= read -r name; do
|
|
[ -e "$DIST/$name" ] && continue
|
|
lines+=("$(grep -E "^[0-9a-f]{64} $name\$" "$EXISTING/sha256sums.txt")")
|
|
done <<< "$existing"
|
|
fi
|
|
|
|
while IFS= read -r name; do
|
|
[ -n "$name" ] && lines+=("$(cd "$DIST" && sha256sum "$name")")
|
|
done <<< "$(binaries "$DIST")"
|
|
|
|
[ ${#lines[@]} -gt 0 ] || { echo "::error::no binaries to list" >&2; exit 1; }
|
|
printf '%s\n' "${lines[@]}" | sort -k2 > "$DIST/sha256sums.txt"
|
|
cat "$DIST/sha256sums.txt"
|