#!/usr/bin/env bash # Assembles the plugin release zip and its .sha256 sidecar from a Release build. # # The layout is the one the OpenAC launcher's installer accepts: # - plugin.json and the entry DLL sit at the zip root; # - only these extensions: .dll .pdb .json .xml .txt .md .png .jpg .jpeg .ttf .otf; # - no runtimes/ folder, and no AcDream assembly beside the plugin's own; # - the plugin.json published as its own release asset is the same file as the # zip's copy; # - the sidecar is `sha256sum`'s line: the hash, two spaces, the zip's name. # Asset names are -.zip and -.zip.sha256. set -euo pipefail configuration="${1:-Release}" output="${2:-artifacts}" repo="$(cd "$(dirname "$0")/.." && pwd)" build="$repo/src/OpenAC.MosswartMassacre/bin/$configuration/net10.0" [ -d "$build" ] || { echo "No build output at $build. Build the solution first." >&2; exit 1; } read_field() { python3 -c 'import json,sys; print(json.load(open(sys.argv[1], encoding="utf-8-sig"))[sys.argv[2]])' "$build/plugin.json" "$1" } id="$(read_field id)" version="$(read_field version)" entry="$(read_field entryDll)" stem="${entry%.dll}" staging="$(mktemp -d)" trap 'rm -rf "$staging"' EXIT for name in plugin.json "$entry" "$stem.pdb" "$stem.deps.json" Newtonsoft.Json.dll; do [ -f "$build/$name" ] || { echo "The build output has no '$name'." >&2; exit 1; } cp "$build/$name" "$staging/" done cp "$build"/mosswartmassacre-*.xml "$staging/" for file in "$staging"/*; do name="$(basename "$file")" case "${name,,}" in *.dll|*.pdb|*.json|*.xml|*.txt|*.md|*.png|*.jpg|*.jpeg|*.ttf|*.otf) ;; *) echo "'$name' has an extension the launcher refuses." >&2; exit 1 ;; esac if [[ "$name" == AcDream.*.dll ]]; then echo "'$name' is a client assembly beside the plugin." >&2; exit 1 fi done mkdir -p "$repo/$output" zip="$repo/$output/$id-$version.zip" rm -f "$zip" python3 - "$staging" "$zip" <<'PY' import os, sys, zipfile src, dst = sys.argv[1], sys.argv[2] with zipfile.ZipFile(dst, "w", zipfile.ZIP_DEFLATED) as z: for name in sorted(os.listdir(src)): z.write(os.path.join(src, name), name) PY (cd "$repo/$output" && sha256sum "$id-$version.zip" > "$id-$version.zip.sha256") cp "$build/plugin.json" "$repo/$output/plugin.json" echo "zip=$zip" echo "version=$version"