All checks were successful
Test and publish WordPress plugin / release (push) Successful in 33s
23 lines
1.2 KiB
Python
23 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Build only the four plugin runtime files; exclude tests, config and Git data."""
|
|
from pathlib import Path
|
|
import hashlib, re, sys, zipfile
|
|
root = Path(__file__).resolve().parents[1]
|
|
main = (root / 'jenhome-contact-exports.php').read_text()
|
|
version = re.search(r'^ \* Version: (\d+\.\d+\.\d+)$', main, re.M).group(1)
|
|
assert f"const VERSION = '{version}';" in main, 'Header/runtime version mismatch'
|
|
if len(sys.argv) > 1:
|
|
assert sys.argv[1] == 'v' + version, 'Tag must match plugin version'
|
|
out = root / 'dist'
|
|
out.mkdir(exist_ok=True)
|
|
package = out / f'jenhome-contact-exports-{version}.zip'
|
|
with zipfile.ZipFile(package, 'w', zipfile.ZIP_DEFLATED) as archive:
|
|
for filename in ['jenhome-contact-exports.php', 'forms.js', 'crm-display.php', 'gitea-updater.php']:
|
|
entry = zipfile.ZipInfo('jenhome-contact-exports/' + filename, (2026, 1, 1, 0, 0, 0))
|
|
entry.compress_type = zipfile.ZIP_DEFLATED
|
|
entry.external_attr = 0o100644 << 16
|
|
archive.writestr(entry, (root / filename).read_bytes())
|
|
checksum = hashlib.sha256(package.read_bytes()).hexdigest()
|
|
package.with_suffix('.zip.sha256').write_text(f'{checksum} {package.name}\n')
|
|
print(f'Built {package.name} SHA256 {checksum}')
|