feat: add gdu static musl build + generalize publish_release.py
This commit is contained in:
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
VERSION="${1:?usage: build_gdu.sh <version> [output_dir]}"
|
||||
OUTPUT_DIR="${2:-$PWD/dist}"
|
||||
PREFIX_NAME="gdu-${VERSION}-linux-amd64-musl-static"
|
||||
|
||||
# strip leading 'v' if passed
|
||||
VERSION="${VERSION#v}"
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
file \
|
||||
go \
|
||||
git \
|
||||
tar \
|
||||
xz
|
||||
|
||||
# gdu uses Go modules, pull source from GitHub
|
||||
SRCDIR="${TMPDIR:-/tmp}/gdu-src-${VERSION}"
|
||||
rm -rf "$SRCDIR"
|
||||
mkdir -p "$SRCDIR"
|
||||
|
||||
curl -fsSL "https://github.com/dundee/gdu/archive/refs/tags/v${VERSION}.tar.gz" \
|
||||
| tar -xz -C "$SRCDIR" --strip-components=1
|
||||
|
||||
cd "$SRCDIR"
|
||||
|
||||
# Build fully static with musl toolchain
|
||||
# CGO_ENABLED=0 forces pure-Go, which means no C deps at all
|
||||
# ldflags: strip debug + disable dynamic linking
|
||||
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux \
|
||||
go build \
|
||||
-trimpath \
|
||||
-ldflags="-s -w -extldflags=-static" \
|
||||
-o "$OUTPUT_DIR/$PREFIX_NAME" \
|
||||
./cmd/gdu
|
||||
|
||||
strip "$OUTPUT_DIR/$PREFIX_NAME" 2>/dev/null || true
|
||||
|
||||
(
|
||||
cd "$OUTPUT_DIR"
|
||||
tar -czf "${PREFIX_NAME}.tar.gz" "$PREFIX_NAME"
|
||||
sha256sum "$PREFIX_NAME" "${PREFIX_NAME}.tar.gz" > "${PREFIX_NAME}.sha256"
|
||||
)
|
||||
|
||||
file "$OUTPUT_DIR/$PREFIX_NAME"
|
||||
ldd "$OUTPUT_DIR/$PREFIX_NAME" || true
|
||||
|
||||
if file "$OUTPUT_DIR/$PREFIX_NAME" | grep -qi 'dynamically linked'; then
|
||||
echo "error: output binary is still dynamically linked" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "build OK: $OUTPUT_DIR/$PREFIX_NAME"
|
||||
@@ -93,10 +93,11 @@ def main() -> int:
|
||||
if missing:
|
||||
raise SystemExit(f"missing files: {', '.join(missing)}")
|
||||
|
||||
tag = f"iperf3-v{version}"
|
||||
title = f"iperf3 {version}"
|
||||
tool = os.environ.get("TOOL", "iperf3")
|
||||
tag = f"{tool}-v{version}"
|
||||
title = f"{tool} {version}"
|
||||
body = (
|
||||
f"Static musl build for iperf3 {version}.\\n\\n"
|
||||
f"Static musl build for {tool} {version}.\\n\\n"
|
||||
f"Repository: {owner}/{repo}\\n"
|
||||
f"Commit: {target}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user