#!/bin/sh # Release a new plugin version: ./build.sh 1.0.3.0 "What changed" # Builds in the official .NET 10 SDK container (only Docker is needed), writes # dist/lightsofftimer_.zip and adds that version to manifest.json. set -eu VERSION=${1:?usage: ./build.sh ""} CHANGELOG=${2:-} TARGET_ABI=${TARGET_ABI:-12.2.0.0} RAW_BASE=${RAW_BASE:-https://git.piskot.si/nikrozman/jellyfin-lights-out-ha/raw/branch/master} PROJ=src/Jellyfin.Plugin.LightsOffTimer/Jellyfin.Plugin.LightsOffTimer.csproj cd "$(dirname "$0")" sed -i.bak -E "s#<(Assembly|File)Version>[^<]+#<\1Version>$VERSION#g" "$PROJ" && rm -f "$PROJ.bak" rm -rf .build src/Jellyfin.Plugin.LightsOffTimer/bin src/Jellyfin.Plugin.LightsOffTimer/obj docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp -e DOTNET_CLI_HOME=/tmp -e DOTNET_NOLOGO=1 \ -v "$PWD":/repo -w /repo mcr.microsoft.com/dotnet/sdk:10.0 \ dotnet publish "$PROJ" -c Release -o /repo/.build python3 - "$VERSION" "$CHANGELOG" "$TARGET_ABI" "$RAW_BASE" <<'PY' import datetime, hashlib, json, pathlib, sys, zipfile version, changelog, abi, raw = sys.argv[1:5] dist = pathlib.Path("dist"); dist.mkdir(exist_ok=True) zip_name = f"lightsofftimer_{version}.zip" with zipfile.ZipFile(dist / zip_name, "w", zipfile.ZIP_DEFLATED) as z: z.write(".build/Jellyfin.Plugin.LightsOffTimer.dll", "Jellyfin.Plugin.LightsOffTimer.dll") md5 = hashlib.md5((dist / zip_name).read_bytes()).hexdigest() path = pathlib.Path("manifest.json") manifest = json.loads(path.read_text()) if path.exists() else [{ "guid": "6b1c3f0e-6f2a-4c55-9d1e-4a7e2c9b5d31", "name": "Lights Off Timer", "description": "Sleep timer next to the volume control in the web player (default: end of this episode/movie). When playback stops, Home Assistant turns the lights off after a cooldown.", "overview": "Sleep timer + Home Assistant lights off", "owner": "nikrozman", "category": "General", "versions": [], }] plugin = manifest[0] plugin["versions"] = [v for v in plugin["versions"] if v["version"] != version] plugin["versions"].insert(0, { "version": version, "changelog": changelog, "targetAbi": abi, "sourceUrl": f"{raw}/dist/{zip_name}", "checksum": md5, "timestamp": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), }) path.write_text(json.dumps(manifest, indent=2) + "\n") print(f"dist/{zip_name} md5 {md5} (targetAbi {abi})") PY rm -rf .build