Null-DRM-Official/scripts/build-release.sh
404errordeveloper da8e1123ec
All checks were successful
release / build-and-upload (push) Successful in 7m5s
Streamd v0.2.0: rename, modules panel, stable/beta channels
- Rename product/host binary to streamd (drm compat copy still shipped)
- Go module path streamd; STREAMD_* env aliases; agent UA streamd-agent
- Panel Modules store + agent pull sync (modstore / modsync)
- Rolling stable + beta download tags; README/docs channel curl blocks
- Release notes in docs/releases/v0.2.0.md attached by Forgejo Actions
2026-10-10 15:58:26 +02:00

118 lines
3.2 KiB
Bash

#!/usr/bin/env bash
# Cross-compile host `streamd` (+ `drm` compat copy) 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}"
local compat="drm-${goos}-${goarch}${ext}"
echo " - $name (+ $compat)"
(
cd "$ROOT"
GOOS="$goos" GOARCH="$goarch" CGO_ENABLED=0 \
"$GO" -C apps/cli build -trimpath -ldflags="-s -w" -o "$OUT/$name" .
)
cp -f "$OUT/$name" "$OUT/$compat"
}
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"
cp -f "$OUT/streamd-linux-amd64" "$ROOT/bin/drm"
;;
aarch64)
cp -f "$OUT/streamd-linux-arm64" "$ROOT/bin/streamd"
cp -f "$OUT/streamd-linux-arm64" "$ROOT/bin/drm"
;;
esac
;;
Darwin)
arch="$(uname -m)"
case "$arch" in
x86_64)
cp -f "$OUT/streamd-darwin-amd64" "$ROOT/bin/streamd"
cp -f "$OUT/streamd-darwin-amd64" "$ROOT/bin/drm"
;;
arm64)
cp -f "$OUT/streamd-darwin-arm64" "$ROOT/bin/streamd"
cp -f "$OUT/streamd-darwin-arm64" "$ROOT/bin/drm"
;;
esac
;;
esac
(
cd "$OUT"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum streamd-* drm-* proxy-android-arm64 > SHA256SUMS.txt
else
shasum -a 256 streamd-* drm-* proxy-android-arm64 > SHA256SUMS.txt
fi
)
echo "==> done ($VERSION)"
ls -la "$OUT"