Restrict release archive contents
Build renameable item readme / build (push) Successful in 9s
Package resourcepack release / release (push) Successful in 4s

This commit is contained in:
2026-08-12 13:22:47 +01:00
parent 68e165c37b
commit b3e1eaaae7
+17 -4
View File
@@ -19,16 +19,29 @@ def log(message: str) -> None:
print(message, file=sys.stderr, flush=True)
def add_payload_file(archive: zipfile.ZipFile, source_file: Path, relative_path: Path) -> None:
if source_file.exists() and source_file.is_file():
archive.write(source_file, relative_path.as_posix())
def zip_resourcepack(resourcepack_root: Path, archive_path: Path) -> None:
archive_path.parent.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(archive_path, mode="w", compression=zipfile.ZIP_DEFLATED) as archive:
for source_file in sorted(resourcepack_root.rglob("*")):
if source_file.is_dir():
add_payload_file(archive, resourcepack_root / "pack.mcmeta", Path("pack.mcmeta"))
add_payload_file(archive, resourcepack_root / "pack.png", Path("pack.png"))
for directory_name in ("assets", "data"):
directory = resourcepack_root / directory_name
if not directory.is_dir():
continue
relative_path = source_file.relative_to(resourcepack_root).as_posix()
archive.write(source_file, relative_path)
for source_file in sorted(directory.rglob("*")):
if source_file.is_dir():
continue
relative_path = source_file.relative_to(resourcepack_root)
archive.write(source_file, relative_path.as_posix())
def request_json(request: urllib.request.Request) -> dict[str, object]: