Files
seaweedfs/seaweed-block/.github/scripts/release-binary-assets.sh
T
pingqiuandClaude Opus 5.5 e403ac4c9d seaweed-block: sw-block mini starts as any user with no sudo
blockvolume gets --volume-lock-dir, a trial-run override of the host
volume lock directory (refused under systemd and together with the test
override). sw-block mini passes <dir>/locks to its holder, so it starts
as any user on a host without /run/sw-block. mini also runs v1 with no
scheduled snapshot (it prints the command that takes one), names
sw-block and weed by their absolute paths in every command it prints,
and after a failed start stops what it started and prints the --reuse
command for the same --dir. The release archive carries
sw-block.tmpfiles.conf for the units' lock directory. The README Quick
Start drops its sudo lines, and the v1.1.1 known issue reads fixed in
v1.1.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 20:45:33 -08:00

52 lines
2.3 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
# The tmpfiles.d entry that creates the host volume lock directory for the units.
cp -- "$(dirname -- "$0")/../../deploy/systemd/sw-block.tmpfiles.conf" "$work/bin/sw-block.tmpfiles.conf"
mkdir -p "$out"
asset="sw-block-${tag}-linux-amd64.tar.gz"
tar -C "$work/bin" -czf "$out/$asset" blockmaster blockvolume sw-block sw-block.tmpfiles.conf
(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