Files

43 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""Build the WordPress ZIP from explicitly listed release files."""
from pathlib import Path
import re
import sys
from zipfile import ZIP_DEFLATED, ZipFile
from sync_shared import verify_shared
root = Path(__file__).resolve().parents[1]
verify_shared(root)
destination = Path(sys.argv[1]) if len(sys.argv) > 1 else root / "dist"
version = re.search(r"^ \* Version: (\S+)$", (root / "hg-socialfeed.php").read_text(), re.MULTILINE)
if not version:
raise SystemExit("Missing plugin version")
files = (
"hg-socialfeed.php",
"README.md",
"readme.txt",
"LICENSE",
"includes/hg-admin-menu.php",
"includes/hg-plugin-updates.php",
"includes/admin.php",
"includes/sources.php",
"includes/instagram.php",
"includes/facebook.php",
"includes/x.php",
"includes/shortcode.php",
"assets/hg-admin-menu.css",
"assets/admin.css",
"assets/feed.css",
"assets/feed.js",
)
destination.mkdir(parents=True, exist_ok=True)
release = destination / f"hg-socialfeed-{version[1]}.zip"
with ZipFile(release, "w", ZIP_DEFLATED) as archive:
for file in files:
archive.write(root / file, Path("hg_socialfeed") / file)
print(release.resolve())