feat: add gdu static musl build + generalize publish_release.py
This commit is contained in:
@@ -0,0 +1,69 @@
|
|||||||
|
name: gdu static musl build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- .gitea/workflows/gdu.yml
|
||||||
|
- scripts/build_gdu.sh
|
||||||
|
- versions/gdu.version
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-release:
|
||||||
|
runs-on: alpine-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Bootstrap workspace
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
REPO_URL: ${{ gitea.server_url }}
|
||||||
|
REPO_NAME: ${{ gitea.repository }}
|
||||||
|
GIT_SHA: ${{ gitea.sha }}
|
||||||
|
run: |
|
||||||
|
apk add --no-cache git
|
||||||
|
workdir="$(pwd)"
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
git clone --depth 1 "$REPO_URL/$REPO_NAME.git" "$tmpdir/repo"
|
||||||
|
git -C "$tmpdir/repo" fetch --depth 1 origin "$GIT_SHA"
|
||||||
|
git -C "$tmpdir/repo" checkout "$GIT_SHA"
|
||||||
|
find "$workdir" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
|
||||||
|
cp -a "$tmpdir/repo"/. "$workdir"/
|
||||||
|
|
||||||
|
- name: Read version
|
||||||
|
id: meta
|
||||||
|
shell: sh
|
||||||
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
run: |
|
||||||
|
version="$(tr -d ' \n\r' < versions/gdu.version)"
|
||||||
|
artifact="gdu-${version}-linux-amd64-musl-static"
|
||||||
|
echo "version=${version}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "artifact=${artifact}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build static gdu
|
||||||
|
shell: sh
|
||||||
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/build_gdu.sh
|
||||||
|
./scripts/build_gdu.sh "${{ steps.meta.outputs.version }}" "$PWD/dist"
|
||||||
|
|
||||||
|
- name: Publish release assets
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ gitea.token }}
|
||||||
|
GITEA_API_URL: ${{ gitea.api_url }}
|
||||||
|
REPO_OWNER: ${{ gitea.repository_owner }}
|
||||||
|
REPO_NAME: static-musl-builds
|
||||||
|
TOOL: gdu
|
||||||
|
VERSION: ${{ steps.meta.outputs.version }}
|
||||||
|
TARGET_SHA: ${{ gitea.sha }}
|
||||||
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
run: |
|
||||||
|
python3 scripts/publish_release.py \
|
||||||
|
"dist/${{ steps.meta.outputs.artifact }}" \
|
||||||
|
"dist/${{ steps.meta.outputs.artifact }}.tar.gz" \
|
||||||
|
"dist/${{ steps.meta.outputs.artifact }}.sha256"
|
||||||
@@ -59,6 +59,7 @@ jobs:
|
|||||||
GITEA_API_URL: ${{ gitea.api_url }}
|
GITEA_API_URL: ${{ gitea.api_url }}
|
||||||
REPO_OWNER: ${{ gitea.repository_owner }}
|
REPO_OWNER: ${{ gitea.repository_owner }}
|
||||||
REPO_NAME: static-musl-builds
|
REPO_NAME: static-musl-builds
|
||||||
|
TOOL: iperf3
|
||||||
VERSION: ${{ steps.meta.outputs.version }}
|
VERSION: ${{ steps.meta.outputs.version }}
|
||||||
TARGET_SHA: ${{ gitea.sha }}
|
TARGET_SHA: ${{ gitea.sha }}
|
||||||
working-directory: ${{ gitea.workspace }}
|
working-directory: ${{ gitea.workspace }}
|
||||||
|
|||||||
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:
|
if missing:
|
||||||
raise SystemExit(f"missing files: {', '.join(missing)}")
|
raise SystemExit(f"missing files: {', '.join(missing)}")
|
||||||
|
|
||||||
tag = f"iperf3-v{version}"
|
tool = os.environ.get("TOOL", "iperf3")
|
||||||
title = f"iperf3 {version}"
|
tag = f"{tool}-v{version}"
|
||||||
|
title = f"{tool} {version}"
|
||||||
body = (
|
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"Repository: {owner}/{repo}\\n"
|
||||||
f"Commit: {target}"
|
f"Commit: {target}"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
5.36.1
|
||||||
Reference in New Issue
Block a user