first commit
This commit is contained in:
commit
2eb8aac027
91 files changed
+20139
No files matched your search
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
EXCLUDED_DIRS = {'.git', '.dev', 'target', 'dist', 'packages', '__pycache__'}
|
||||
EXCLUDED_NAMES = {'.env'}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) != 2:
|
||||
print(f'usage: {Path(sys.argv[0]).name} OUTPUT.zip', file=sys.stderr)
|
||||
return 2
|
||||
output = Path(sys.argv[1]).resolve()
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
prefix = f'PostfixAdmin-RS-{project_version()}'
|
||||
with zipfile.ZipFile(output, 'w', compression=zipfile.ZIP_DEFLATED, compresslevel=9) as archive:
|
||||
for path in sorted(ROOT.rglob('*')):
|
||||
if not path.is_file() or path.resolve() == output:
|
||||
continue
|
||||
rel = path.relative_to(ROOT)
|
||||
if any(part in EXCLUDED_DIRS for part in rel.parts) or rel.name in EXCLUDED_NAMES:
|
||||
continue
|
||||
archive.write(path, f'{prefix}/{rel.as_posix()}')
|
||||
return 0
|
||||
|
||||
|
||||
def project_version() -> str:
|
||||
import tomllib
|
||||
with (ROOT / 'Cargo.toml').open('rb') as handle:
|
||||
return tomllib.load(handle)['package']['version']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user