-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump_version.py
64 lines (48 loc) · 1.91 KB
/
bump_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sys
import re
# Check if a new version was provided
if len(sys.argv) < 2:
print("Usage: python script.py <new_version>")
sys.exit(1)
# Get the new version from the command line arguments
new_version = sys.argv[1]
# ---------- update the main Cargo
# Read the Cargo.toml file
with open("Cargo.toml", "r") as file:
lines = file.readlines()
# Update the version in the Cargo.toml file
for i in range(len(lines)):
if lines[i].startswith("version ="):
lines[i] = f'version = "{new_version}"\n' # Update the line with the new version
break # Exit the loop once the version is updated
# Write the updated content back to Cargo.toml
with open("Cargo.toml", "w") as file:
file.writelines(lines)
# Log the update process
print(f"Updated Cargo.toml to version {new_version}")
# --------------------------------------
# ---------- update the stemlib Cargo
# Read the Cargo.toml file
with open("stemlib/Cargo.toml", "r") as file:
lines = file.readlines()
# Update the version in the Cargo.toml file
for i in range(len(lines)):
if lines[i].startswith("version ="):
lines[i] = f'version = "{new_version}"\n' # Update the line with the new version
break # Exit the loop once the version is updated
# Write the updated content back to Cargo.toml
with open("stemlib/Cargo.toml", "w") as file:
file.writelines(lines)
# Log the update process
print(f"Updated stemlib/Cargo.toml to version {new_version}")
# --------------------------------------
# Update the version in Dockerfile
with open("Dockerfile", "r") as file:
dockerfile = file.read()
# Update the version label in the Dockerfile
dockerfile = re.sub(r'LABEL version=".*"', f'LABEL version="{new_version}"', dockerfile)
# Write the updated content back to Dockerfile
with open("Dockerfile", "w") as file:
file.write(dockerfile)
# Log the update process for Dockerfile
print(f"Updated Dockerfile to version {new_version}")