feat: add more static musl tools
busybox static musl build / build-and-release (push) Failing after 31s
doggo static musl build / build-and-release (push) Successful in 19s
gdu static musl build / build-and-release (push) Successful in 37s
iperf3 static musl build / build-and-release (push) Successful in 20s
speedtest-go static musl build / build-and-release (push) Successful in 32s
busybox static musl build / build-and-release (push) Failing after 31s
doggo static musl build / build-and-release (push) Successful in 19s
gdu static musl build / build-and-release (push) Successful in 37s
iperf3 static musl build / build-and-release (push) Successful in 20s
speedtest-go static musl build / build-and-release (push) Successful in 32s
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
VERSION="${1:?usage: build_doggo.sh <version> [output_dir]}"
|
||||
OUTPUT_DIR="${2:-$PWD/dist}"
|
||||
VERSION="${VERSION#v}"
|
||||
PREFIX_NAME="doggo-${VERSION}-linux-amd64-musl-static"
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
apk add --no-cache curl file go git tar xz
|
||||
|
||||
SRCDIR="${TMPDIR:-/tmp}/doggo-src-${VERSION}"
|
||||
rm -rf "$SRCDIR"
|
||||
mkdir -p "$SRCDIR"
|
||||
|
||||
curl -fsSL "https://github.com/mr-karan/doggo/archive/refs/tags/v${VERSION}.tar.gz" | tar -xz -C "$SRCDIR" --strip-components=1
|
||||
|
||||
cd "$SRCDIR"
|
||||
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -trimpath -ldflags="-s -w -extldflags=-static" -o "$OUTPUT_DIR/$PREFIX_NAME" ./cmd/doggo
|
||||
|
||||
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"
|
||||
Reference in New Issue
Block a user