37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
#!/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
|
||
|
|
|
||
|
|
|
||
|
|
root = Path(__file__).resolve().parents[1]
|
||
|
|
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/admin.php",
|
||
|
|
"includes/sources.php",
|
||
|
|
"includes/instagram.php",
|
||
|
|
"includes/facebook.php",
|
||
|
|
"includes/x.php",
|
||
|
|
"includes/shortcode.php",
|
||
|
|
"assets/hg-admin-menu.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())
|