mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
Merge note (batch b5; pull_request_target spec-trace workflow has a startup_failure, so its checks run locally): - One Test run (47198949595) succeeded (go test (linux), process-level tests (real binaries)) on the integration tree 22da3420 = main 5bf18d62 + #1011 #1012 in this order; these squash merges reproduce that tree, verified after the last one. - spec-trace-check.sh and public-text-check.sh, run with main's scripts against this head and body: both exit 0. - Code review ACCEPT on 501f43f7: on a release tag the publish workflow takes the three Linux binaries unchanged out of the just-pushed image by digest, refuses dirty, unknown, lab-tagged or mismatched revisions, uploads the tarball and SHA256SUMS, sets the pre-release flag from the tag form on new and existing releases, and cleans up both owned resources while keeping the first failure. - Workflow review: publish workflow and its helper script reviewed at this exact head.
50 lines
2.1 KiB
Bash
50 lines
2.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Copy release executables unchanged from the exact published Linux image.
|
|
set -euo pipefail
|
|
[ "$#" = 4 ] || { echo "usage: release-binary-assets.sh IMAGE@DIGEST REVISION TAG OUT" >&2; exit 2; }
|
|
image=$1; revision=$2; tag=$3; out=$4
|
|
[[ "$image" =~ @sha256:[a-f0-9]{64}$ ]] || { echo "an immutable image digest is required" >&2; exit 2; }
|
|
[[ "$revision" =~ ^[a-f0-9]{40}$ ]] || { echo "a full Git revision is required" >&2; exit 2; }
|
|
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]] || { echo "invalid release tag" >&2; exit 2; }
|
|
work=$(mktemp -d)
|
|
container=
|
|
cleanup() {
|
|
local status=$? cleanup_status=0 next_status=0
|
|
trap - EXIT
|
|
if [ -n "$container" ]; then
|
|
docker rm "$container" >/dev/null || cleanup_status=$?
|
|
fi
|
|
rm -rf -- "${work:?}" || {
|
|
next_status=$?
|
|
if [ "$cleanup_status" = 0 ]; then cleanup_status=$next_status; fi
|
|
}
|
|
if [ "$status" = 0 ]; then status=$cleanup_status; fi
|
|
exit "$status"
|
|
}
|
|
trap cleanup EXIT
|
|
mkdir -p "$work/bin"
|
|
docker pull "$image"
|
|
container=$(docker create "$image")
|
|
for binary in blockmaster blockvolume sw-block; do
|
|
docker cp "$container:/usr/local/bin/$binary" "$work/bin/$binary"
|
|
version=$("$work/bin/$binary" -version)
|
|
if [ "$version" != "$binary revision=$revision modified=false" ]; then
|
|
echo "$binary revision mismatch: expected $revision modified=false, got $version" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
mkdir -p "$out"
|
|
asset="sw-block-${tag}-linux-amd64.tar.gz"
|
|
tar -C "$work/bin" -czf "$out/$asset" blockmaster blockvolume sw-block
|
|
(cd "$out" && sha256sum "$asset" >SHA256SUMS)
|
|
prerelease=false
|
|
if [[ "$tag" == *-* ]]; then prerelease=true; fi
|
|
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
gh release edit "$tag" --repo "$GITHUB_REPOSITORY" --prerelease="$prerelease"
|
|
gh release upload "$tag" "$out/$asset" "$out/SHA256SUMS" --repo "$GITHUB_REPOSITORY" --clobber
|
|
else
|
|
args=(--repo "$GITHUB_REPOSITORY" --verify-tag --title "Seaweed Block $tag" --generate-notes)
|
|
args+=(--prerelease="$prerelease")
|
|
gh release create "$tag" "$out/$asset" "$out/SHA256SUMS" "${args[@]}"
|
|
fi
|