Null-DRM-Official/scripts/build-release.sh
404errordeveloper 8fc7e4c0b8 streamd: serve start/stop/update, streamd.yaml, egress, module panel fixes
- Add streamd serve start|stop|restart|status|update with auto-written streamd.yaml
- Panel modules: STREAMD_MODULES_DIR for describe, YAML channel fallback, textarea value fix
- Per-stream WireGuard/SOCKS egress profiles + Settings UI
- Drop drm-* from release builds; track streamd-bg.sh / streamd-update.sh wrappers
- Docs: streamd-server-setup lifecycle and update flow
2026-10-10 18:05:51 +02:00

103 lines
2.8 KiB
Bash

#!/usr/bin/env bash
# Cross-compile host `streamd` and on-device `proxy-android-arm64` into dist/release/.
# Usage:
# ./scripts/build-release.sh # VERSION=git describe
# ./scripts/build-release.sh v1.2.3
# OUT=dist/release ./scripts/build-release.sh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="${OUT:-$ROOT/dist/release}"
VERSION="${1:-}"
if [[ -z "$VERSION" ]]; then
VERSION="$(git -C "$ROOT" describe --tags --always --dirty 2>/dev/null || echo dev)"
fi
# Resolve go even when it is not on PATH (e.g. Windows go-sdk install).
resolve_go() {
if command -v go >/dev/null 2>&1; then
command -v go
return
fi
local c
for c in \
"${GOROOT:+$GOROOT/bin/go}" \
"$HOME/go-sdk/go/bin/go" \
"$HOME/sdk/go/bin/go" \
"$HOME/go/bin/go" \
"/usr/local/go/bin/go" \
"/usr/lib/go/bin/go"
do
if [[ -n "$c" && -x "$c" ]]; then
echo "$c"
return
fi
done
echo "go not found on PATH or in common locations" >&2
exit 1
}
GO="$(resolve_go)"
echo "==> using $GO"
"$GO" version
mkdir -p "$OUT"
rm -f "$OUT"/streamd-* "$OUT"/drm-* "$OUT"/proxy-android-arm64 "$OUT"/SHA256SUMS.txt 2>/dev/null || true
echo "==> building host streamd ($VERSION) into $OUT"
build_host() {
local goos="$1" goarch="$2" ext="${3:-}"
local name="streamd-${goos}-${goarch}${ext}"
echo " - $name"
(
cd "$ROOT"
GOOS="$goos" GOARCH="$goarch" CGO_ENABLED=0 \
"$GO" -C apps/cli build -trimpath -ldflags="-s -w" -o "$OUT/$name" .
)
}
build_host windows amd64 .exe
build_host windows arm64 .exe
build_host linux amd64
build_host linux arm64
build_host darwin amd64
build_host darwin arm64
echo "==> building on-device MITM (linux/arm64)"
(
cd "$ROOT/apps/proxy/device"
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
"$GO" build -trimpath -ldflags='-s -w' -o "$OUT/proxy-android-arm64" .
)
# Also copy into the usual local paths for convenience when run by hand.
mkdir -p "$ROOT/bin" "$ROOT/apps/proxy"
cp -f "$OUT/proxy-android-arm64" "$ROOT/bin/proxy-android-arm64"
cp -f "$OUT/proxy-android-arm64" "$ROOT/apps/proxy/proxy-android-arm64"
case "$(uname -s)" in
Linux)
arch="$(uname -m)"
case "$arch" in
x86_64) cp -f "$OUT/streamd-linux-amd64" "$ROOT/bin/streamd" ;;
aarch64) cp -f "$OUT/streamd-linux-arm64" "$ROOT/bin/streamd" ;;
esac
;;
Darwin)
arch="$(uname -m)"
case "$arch" in
x86_64) cp -f "$OUT/streamd-darwin-amd64" "$ROOT/bin/streamd" ;;
arm64) cp -f "$OUT/streamd-darwin-arm64" "$ROOT/bin/streamd" ;;
esac
;;
esac
(
cd "$OUT"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum streamd-* proxy-android-arm64 > SHA256SUMS.txt
else
shasum -a 256 streamd-* proxy-android-arm64 > SHA256SUMS.txt
fi
)
echo "==> done ($VERSION)"
ls -la "$OUT"