forked from Nayjest/Gito
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti-build.py
More file actions
46 lines (39 loc) · 1.08 KB
/
multi-build.py
File metadata and controls
46 lines (39 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Multi-build script for delivering to PYPI with aliased names.
(c) Vitalii Stepanenko (Nayjest) <mailto:mail@vitaliy.in>, 2025
"""
import re
from pathlib import Path
import subprocess
NAMES = [
["gito.bot"],
["ai-code-review"],
["ai-cr"],
["github-code-review"],
]
FILES = [
"pyproject.toml",
]
def replace_name(old_names: list[str], new_names: list[str], files: list[str] = None):
files = files or FILES
for i in range(len(old_names)):
old_name = old_names[i]
new_name = new_names[i]
for path in files:
p = Path(path)
p.write_text(
re.sub(
rf"(?<![\\/\w\-\_]){old_name}\b",
new_name,
p.read_text(encoding="utf-8"),
flags=re.M,
),
encoding="utf-8",
)
prev = NAMES[0]
for nxt in NAMES[1:] + [NAMES[0]]:
print(f"Building for project name: {nxt[0]}...")
replace_name(prev, nxt)
subprocess.run(["poetry", "build"], check=True)
prev = nxt
print("All builds completed.")