-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
version.py
48 lines (42 loc) · 1.2 KB
/
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
39
40
41
42
43
44
45
46
47
48
import os
import subprocess
import sys
def set_client_version(part: str):
os.chdir("./client")
subprocess.run(["poetry", "version", part])
version = subprocess.run(
["poetry", "version", "-s"],
capture_output=True,
text=True,
).stdout.rstrip()
if sys.platform == "darwin":
subprocess.run(
[
"sed",
"-i",
"",
f's/__VERSION__ = "[^"]*"/__VERSION__ = "{version}"/g',
"gefyra/configuration.py",
]
)
else:
subprocess.run(
[
"sed",
"-i",
f's/__VERSION__ = "[^"]*"/__VERSION__ = "{version}"/g',
"gefyra/configuration.py",
]
)
def set_operator_version(part: str):
os.chdir("./operator")
subprocess.run(["poetry", "version", part])
if __name__ == "__main__":
if len(sys.argv) != 2 or sys.argv[1] not in ["major", "minor", "patch"]:
print("Only major, minor, patch is allowed as argument")
exit(1)
else:
wd = os.getcwd()
set_client_version(sys.argv[1])
os.chdir(wd)
set_operator_version(sys.argv[1])