openac-mosswartmassacre/tools/build-release-zip.sh
Erik a9c6938f0e
Some checks failed
CI / build-and-test (pull_request) Failing after 47s
CI / release (pull_request) Has been skipped
Build, test and release on the club Gitea
A Forgejo workflow builds and tests every push and pull request on the
club's docker runner. A v* tag also assembles the plugin zip, checks it
with OpenAC's own plugin checker, and publishes a Gitea release with the
zip, its checksum and plugin.json.

The checker refused the manifest: both permission notes were over the
launcher's 120-character limit. They are shorter now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 16:00:00 +02:00

63 lines
2.3 KiB
Bash
Executable file

#!/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 <id>-<version>.zip and <id>-<version>.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"