41 lines
2.0 KiB
Python
41 lines
2.0 KiB
Python
"""Package only distributable files; exclude editor caches and player saves."""
|
|
from pathlib import Path
|
|
import hashlib
|
|
import zipfile
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
builds = root / "builds"
|
|
windows = builds / "Windows"
|
|
with zipfile.ZipFile(builds / "DoOtboy_v0.2_Windows.zip", "w", zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
|
for name in ("DoOtboy.exe", "README_RU.md", "SCENARIO_RU.md", "AUDIO_CREDITS.md", "GODOT_LICENSE.txt"):
|
|
archive.write(windows / name, "DoOtboy/" + name)
|
|
|
|
with zipfile.ZipFile(builds / "DoOtboy_v0.2_Source.zip", "w", zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
|
for name in ("README_RU.md", "SCENARIO_RU.md", "AUDIO_CREDITS.md", "GODOT_LICENSE.txt", "build.ps1", ".gitignore"):
|
|
archive.write(root / name, "DoOtboy/" + name)
|
|
for name in ("make_audio.py", "make_phone_effects.py", "write_phone_story.py", "make_draft_voices.ps1", "package.py"):
|
|
archive.write(root / "tools" / name, "DoOtboy/tools/" + name)
|
|
for path in (root / "do-otboy").rglob("*"):
|
|
if not path.is_file() or ".godot" in path.parts or path.suffix == ".import":
|
|
continue
|
|
archive_name = "DoOtboy/" + path.relative_to(root).as_posix()
|
|
if path.name == "export_presets.cfg":
|
|
portable = path.read_text(encoding="utf-8").replace(
|
|
'custom_template/release="../tools/templates/windows_release_x86_64.exe"',
|
|
'custom_template/release=""',
|
|
)
|
|
archive.writestr(archive_name, portable)
|
|
else:
|
|
archive.write(path, archive_name)
|
|
|
|
for name in ("DoOtboy_v0.2_Windows.zip", "DoOtboy_v0.2_Source.zip"):
|
|
path = builds / name
|
|
digest = hashlib.sha256(path.read_bytes()).hexdigest()
|
|
print(f"{name}: {path.stat().st_size:,} bytes; SHA256 {digest}")
|
|
|
|
with zipfile.ZipFile(builds / "DoOtboy_v0.2_Windows.zip") as archive:
|
|
assert archive.testzip() is None
|
|
with zipfile.ZipFile(builds / "DoOtboy_v0.2_Source.zip") as archive:
|
|
assert archive.testzip() is None
|
|
print("Both ZIP archives verified")
|