68 lines
3.2 KiB
Bash
Executable File
68 lines
3.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# Builds the packaged game (export_presets.cfg) into build/:
|
|
#
|
|
# tools/export.sh # macOS and Windows
|
|
# tools/export.sh macOS # just one ("macOS" or "Windows")
|
|
#
|
|
# build/Cinderwild-<version>-macos.zip the .app (universal: Apple silicon + Intel),
|
|
# ad-hoc signed, not notarised
|
|
# build/Cinderwild-<version>-windows.zip Cinderwild.exe + Cinderwild.pck (+ a console
|
|
# wrapper), unsigned
|
|
#
|
|
# Needs the Godot export templates for this Godot's version (Editor > Manage
|
|
# Export Templates, or the .tpz from the Godot release page).
|
|
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
. tools/godot_env.sh
|
|
|
|
VERSION=$(sed -n 's/^config\/version="\(.*\)"/\1/p' project.godot | head -1)
|
|
PROTOCOL=$(sed -n 's/^const PROTOCOL := \([0-9]*\).*/\1/p' scripts/net/net.gd | head -1)
|
|
# The packages' own version numbers must say the same as the game's.
|
|
for v in $(grep -E '^application/(short_version|version|file_version|product_version)=' export_presets.cfg | sed 's/.*="\(.*\)"/\1/'); do
|
|
if [ "$v" != "$VERSION" ]; then
|
|
echo "export_presets.cfg says $v but project.godot's config/version is $VERSION: make them match"; exit 1
|
|
fi
|
|
done
|
|
which=${1:-all}
|
|
mkdir -p build
|
|
"$GODOT" --headless --path . --import >/dev/null 2>&1
|
|
|
|
if [ "$which" = all ] || [ "$which" = macOS ]; then
|
|
rm -rf build/macos && mkdir -p build/macos
|
|
"$GODOT" --headless --path . --export-release "macOS" build/macos/Cinderwild.zip > build/export-macos.log 2>&1
|
|
if [ -f build/macos/Cinderwild.zip ]; then
|
|
mv build/macos/Cinderwild.zip "build/Cinderwild-$VERSION-macos.zip"
|
|
echo "built build/Cinderwild-$VERSION-macos.zip"
|
|
else
|
|
echo "macOS export failed: see build/export-macos.log"; exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$which" = all ] || [ "$which" = Windows ]; then
|
|
rm -rf build/windows && mkdir -p build/windows/Cinderwild
|
|
"$GODOT" --headless --path . --export-release "Windows" build/windows/Cinderwild/Cinderwild.exe > build/export-windows.log 2>&1
|
|
if [ -f build/windows/Cinderwild/Cinderwild.exe ]; then
|
|
(cd build/windows && rm -f "../Cinderwild-$VERSION-windows.zip" && zip -qr "../Cinderwild-$VERSION-windows.zip" Cinderwild)
|
|
echo "built build/Cinderwild-$VERSION-windows.zip"
|
|
else
|
|
echo "Windows export failed: see build/export-windows.log"; exit 1
|
|
fi
|
|
fi
|
|
|
|
# build/version.json, for the release (scripts/core/updates.gd reads it):
|
|
# upload it with the zips. NOTES="..." tools/export.sh adds a line of notes.
|
|
python3 - "$VERSION" "$PROTOCOL" "${NOTES:-}" <<'EOF'
|
|
import hashlib, json, os, sys, datetime
|
|
version, protocol, notes = sys.argv[1], int(sys.argv[2]), sys.argv[3]
|
|
out = {"version": version, "protocol": protocol, "date": datetime.date.today().isoformat(), "downloads": {}}
|
|
if notes:
|
|
out["notes"] = notes
|
|
for plat in ("macos", "windows"):
|
|
f = "build/Cinderwild-%s-%s.zip" % (version, plat)
|
|
if os.path.exists(f):
|
|
h = hashlib.sha256(open(f, "rb").read()).hexdigest()
|
|
out["downloads"][plat] = {"file": os.path.basename(f), "sha256": h, "size": os.path.getsize(f)}
|
|
json.dump(out, open("build/version.json", "w"), indent="\t")
|
|
print("wrote build/version.json (%s, protocol %d: %s)" % (version, protocol, ", ".join(out["downloads"]) or "no packages"))
|
|
EOF
|