-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathupdate_version.py
38 lines (25 loc) · 952 Bytes
/
update_version.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
32
33
34
35
36
37
38
from pathlib import Path
from subprocess import check_call, check_output
from sys import argv
from sys import exit as sys_exit
def find_hash(ref: str) -> str:
return check_output(['git', 'rev-parse', ref]).decode().strip()
def check_up_to_date(ref: str) -> None:
master_hash = find_hash('master')
release_hash = find_hash(ref)
if master_hash != release_hash:
print("Master and current release are different commits, cannot release")
sys_exit(1)
def checkout_master() -> None:
check_call(['git', 'fetch'])
check_call(['git', 'checkout', 'master'])
def bump_version(ref: str) -> None:
*_, version = ref.split('/')
here = Path(__file__).parent
version_py = here / 'skillbridge' / 'version.py'
version_py.write_text(f"__version__ = '{version}'\n")
if __name__ == '__main__':
_, release_ref = argv
checkout_master()
check_up_to_date(release_ref)
bump_version(release_ref)