Null-DRM-Official/scripts/build-modules-release.sh
404errordeveloper 2e43e6c3fa
All checks were successful
release / build-and-upload (push) Successful in 6m21s
Add ITVX module, transparent mitm_hosts, and DM Telegram announces.
Wire module mitm_hosts into StartTransparent for ITVX capture, ship the
itv provider stub with Live-list autoplay, refresh the README, and send
Forgejo release announces to private chat 7314901602.
2026-10-09 17:35:53 +02:00

68 lines
2 KiB
Bash

#!/usr/bin/env bash
# Build per-module release zips for tag modules-vX.Y.Z
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
VERSION="${1:-}"
OUT="${2:-$ROOT/dist/release}"
if [[ -z "$VERSION" ]]; then
VERSION="$(git -C "$ROOT" describe --tags --always --dirty 2>/dev/null || echo modules-dev)"
fi
mkdir -p "$OUT"
MODULES=(bbc rte tg4 itv)
TARGETS=(
"windows amd64 .exe"
"windows arm64 .exe"
"linux amd64 "
"linux arm64 "
"darwin amd64 "
"darwin arm64 "
)
built=()
for name in "${MODULES[@]}"; do
src="$ROOT/modules/$name"
[[ -f "$src/go.mod" ]] || { echo "SKIP $name"; continue; }
publish="$src/module-publish.yaml"
[[ -f "$publish" ]] || { echo "missing $publish"; exit 1; }
stage="$ROOT/dist/modules/$name"
rm -rf "$stage"
mkdir -p "$stage/.bin"
echo "==> module $name"
while read -r goos goarch ext; do
[[ -z "$goos" ]] && continue
sub="$stage/.bin/${goos}-${goarch}"
mkdir -p "$sub"
bin="$sub/${name}${ext}"
echo " - ${goos}/${goarch} → $bin"
( cd "$src" && CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" \
go build -trimpath -ldflags='-s -w' -o "$bin" . )
done <<< "$(printf '%s\n' "${TARGETS[@]}")"
# Ship module.yaml only (= publish template renamed; no secrets, no module-publish.yaml).
cp "$publish" "$stage/module.yaml"
cat > "$stage/README.md" <<EOF
# $name ($VERSION)
Unpack into \`modules/$name/\`. Edit \`module.yaml\` for secrets. Copy
\`.bin/<goos>-<goarch>/$name\` to \`.bin/$name\` for your OS, or rebuild with Go.
This zip's \`module.yaml\` is the published universal template (secrets empty).
EOF
zip_path="$OUT/${name}.zip"
rm -f "$zip_path"
( cd "$stage" && zip -qr "$zip_path" . )
built+=("$zip_path")
echo " zip $zip_path"
done
sums="$OUT/SHA256SUMS-modules.txt"
: > "$sums"
for z in "${built[@]}"; do
( cd "$(dirname "$z")" && sha256sum "$(basename "$z")" ) >> "$sums"
done
echo "DONE modules release $VERSION → $OUT"
ls -la "$OUT"/bbc.zip "$OUT"/rte.zip "$OUT"/tg4.zip "$OUT"/itv.zip 2>/dev/null || true