112 lines
3.3 KiB
Bash
Executable File
112 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
echo "Usage: $0 --linux PATH --windows PATH" >&2
|
|
exit 2
|
|
}
|
|
|
|
file_size() {
|
|
wc -c < "$1" | tr -d '[:space:]'
|
|
}
|
|
|
|
expected_archive_contents() {
|
|
local root=$1 executable=$2
|
|
printf '%s/\n' "$root"
|
|
printf '%s/%s\n' "$root" "$executable"
|
|
printf '%s/%s\n' "$root" README.md
|
|
printf '%s/%s\n' "$root" LICENSE
|
|
printf '%s/%s\n' "$root" config.toml
|
|
}
|
|
|
|
verify_archive_contents() {
|
|
local archive=$1 root=$2 executable=$3 contents
|
|
case "$archive" in
|
|
*.tar.gz) contents=$(tar -tzf "$archive") ;;
|
|
*.zip) contents=$(zipinfo -1 "$archive") ;;
|
|
*) echo "Unsupported release archive: $archive" >&2; exit 1 ;;
|
|
esac
|
|
|
|
if ! diff -u \
|
|
<(expected_archive_contents "$root" "$executable" | sort) \
|
|
<(printf '%s\n' "$contents" | sort); then
|
|
echo "Release archive contains unexpected or missing files: $archive" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
linux_binary=
|
|
windows_binary=
|
|
while (($#)); do
|
|
case "$1" in
|
|
--linux) linux_binary=${2:-}; shift 2 ;;
|
|
--windows) windows_binary=${2:-}; shift 2 ;;
|
|
*) usage ;;
|
|
esac
|
|
done
|
|
|
|
[[ -n "$linux_binary" && -f "$linux_binary" ]] || usage
|
|
[[ -n "$windows_binary" && -f "$windows_binary" ]] || usage
|
|
|
|
version=$(awk -F '"' '$1 ~ /^version = / { print $2; exit }' Cargo.toml)
|
|
[[ -n "$version" ]] || { echo "Could not read the package version." >&2; exit 1; }
|
|
|
|
index=generated/peq-npc-gender-index.json
|
|
[[ -f "$index" ]] || { echo "Missing generated PEQ index: $index" >&2; exit 1; }
|
|
|
|
dist=dist
|
|
stage=$(mktemp -d)
|
|
repository_root=$PWD
|
|
trap 'rm -rf "$stage"' EXIT
|
|
rm -rf "$dist"
|
|
mkdir -p "$dist"
|
|
|
|
package_tarball() {
|
|
local platform=$1 binary=$2
|
|
local root="mudmouth-v${version}-${platform}"
|
|
mkdir -p "$stage/$root"
|
|
cp "$binary" "$stage/$root/mudmouth"
|
|
cp README.md LICENSE config.toml "$stage/$root/"
|
|
tar -C "$stage" -czf "$dist/$root.tar.gz" "$root"
|
|
rm -rf "$stage/$root"
|
|
}
|
|
|
|
package_tarball x86_64-unknown-linux-gnu "$linux_binary"
|
|
windows_root="mudmouth-v${version}-x86_64-pc-windows-gnu"
|
|
mkdir -p "$stage/$windows_root"
|
|
cp "$windows_binary" "$stage/$windows_root/mudmouth.exe"
|
|
cp README.md LICENSE config.toml "$stage/$windows_root/"
|
|
(
|
|
cd "$stage"
|
|
zip -q -r "$repository_root/$dist/${windows_root}.zip" "$windows_root"
|
|
)
|
|
|
|
linux_archive="$dist/mudmouth-v${version}-x86_64-unknown-linux-gnu.tar.gz"
|
|
windows_archive="$dist/${windows_root}.zip"
|
|
verify_archive_contents "$linux_archive" "mudmouth-v${version}-x86_64-unknown-linux-gnu" mudmouth
|
|
verify_archive_contents "$windows_archive" "$windows_root" mudmouth.exe
|
|
|
|
size_report="$dist/SIZE-REPORT.txt"
|
|
{
|
|
echo "Mudmouth release size report"
|
|
echo
|
|
printf 'Generated PEQ NPC index: %s bytes\n' "$(file_size "$index")"
|
|
printf 'Linux executable: %s bytes\n' "$(file_size "$linux_binary")"
|
|
printf 'Linux .tar.gz: %s bytes\n' "$(file_size "$linux_archive")"
|
|
printf 'Windows executable: %s bytes\n' "$(file_size "$windows_binary")"
|
|
printf 'Windows .zip: %s bytes\n' "$(file_size "$windows_archive")"
|
|
echo
|
|
echo "Archive contents: verified against the release allowlist (binary, README, LICENSE, config.toml)."
|
|
echo "PEQ dumps, generator inputs, fixtures, database files, and source code are absent."
|
|
} > "$size_report"
|
|
|
|
(
|
|
cd "$dist"
|
|
sha256sum -- *.tar.gz *.zip > SHA256SUMS.txt
|
|
)
|
|
|
|
printf 'Created release assets in %s:\n' "$dist"
|
|
cat "$dist/SHA256SUMS.txt"
|
|
printf '\n'
|
|
cat "$size_report"
|