-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbump_version.py
More file actions
25 lines (21 loc) · 923 Bytes
/
bump_version.py
File metadata and controls
25 lines (21 loc) · 923 Bytes
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
import os
import sys
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
FILES_TO_UPDATE = [
os.path.join(PROJECT_ROOT, "README.md"),
os.path.join(PROJECT_ROOT, "tar_docker.py")
]
VERSION_HISTORY = os.path.join(PROJECT_ROOT, "replication_package.version.history")
if __name__ == '__main__':
new_version = sys.argv[1]
with open(VERSION_HISTORY, "r") as version_history_file:
version_history_records = [line.strip() for line in version_history_file.readlines()]
old_version = version_history_records[0].strip()
for file in FILES_TO_UPDATE:
with open(file, "r") as f:
content = f.read()
content = content.replace(old_version, new_version)
with open(file, "w") as f:
f.write(content)
with open(VERSION_HISTORY, "w") as version_history_file:
version_history_file.write("\n".join([new_version] + version_history_records))