forked from NiceneNerd/BCML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvbump.py
32 lines (26 loc) · 1.04 KB
/
vbump.py
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
from pathlib import Path
import sys
version = sys.argv[1]
major, minor, patch = version.split(".")
setup = Path("setup.py")
setup_text = setup.read_text().splitlines()
for i, line in enumerate(setup_text):
if "version=" in line:
setup_text[i] = f' version="{version}",'
setup.write_text("\n".join(setup_text))
version_file = Path("bcml/__version__.py")
version_file_text = version_file.read_text().splitlines()
version_file_text[0:3] = [f"_MAJOR={major}", f"_MINOR={minor}", f'_PATCH="{patch}"']
version_file.write_text("\n".join(version_file_text))
cargo = Path("Cargo.toml")
cargo_text = cargo.read_text().splitlines()
for i, line in enumerate(cargo_text):
if line.startswith("version"):
cargo_text[i] = f'version = "{version}"'
cargo.write_text("\n".join(cargo_text))
pyproject = Path("pyproject.toml")
pyproject_text = pyproject.read_text().splitlines()
for i, line in enumerate(pyproject_text):
if line.startswith("version"):
pyproject_text[i] = f'version = "{version}"'
pyproject.write_text("\n".join(pyproject_text))