forked from Aiven-Open/rohmu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_release.py
executable file
·25 lines (21 loc) · 1.09 KB
/
make_release.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
#!/usr/bin/env python3
import argparse
from pathlib import Path
import re
import subprocess
def make_release(version: str) -> None:
if not re.match(r"\d+\.\d+.\d+", version):
raise ValueError(f"Unexpected version: {version!r}, shoud be N.N.N")
project_directory = Path(__file__).parent
version_filename = project_directory / "rohmu/version.py"
version_filename.write_text(f'VERSION = "{version}"\n')
subprocess.run(["git", "-C", str(project_directory), "add", str(version_filename)], check=True)
subprocess.run(["git", "-C", str(project_directory), "commit", "-m", f"Bump to version {version}"], check=True)
subprocess.run(["git", "-C", str(project_directory), "tag", "-a", f"releases/{version}", "-m", f"Version {version}"], check=True)
subprocess.run(["git", "-C", str(project_directory), "log", "-n", "1", "-p"], check=True)
print("Run 'git push --tags' to confirm the release")
if __name__ == '__main__':
parser = argparse.ArgumentParser("Make a rohmu release")
parser.add_argument("version")
args = parser.parse_args()
make_release(args.version)