-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathver-bump.py
executable file
·39 lines (34 loc) · 1.13 KB
/
ver-bump.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
#!/bin/env python3
import json
import sys
import string
if __name__ == "__main__":
f = open("version.json", "r")
version = json.load(f)
f.close()
try:
if sys.argv[1] == "major":
version["libcomps_VERSION_MAJOR"] += 1
version["libcomps_VERSION_MINOR"] = 1
version["libcomps_VERSION_PATCH"] = 1
version["libcomps_RELEASE"] = 1
elif sys.argv[1] == "minor":
version["libcomps_VERSION_MINOR"] += 1
version["libcomps_VERSION_PATCH"] = 1
version["libcomps_RELEASE"] = 1
elif sys.argv[1] == "patch":
version["libcomps_VERSION_PATCH"] += 1
version["libcomps_RELEASE"] = 1
except IndexError:
version["libcomps_VERSION_PATCH"] += 1
version["libcomps_RELEASE"] = 1
f = open("version.json", "w")
json.dump(version, f, indent=4)
f.close()
f = open("libcomps/version.cmake.in", "r")
version_in = f.read()
f.close()
version_out = string.Template(version_in).substitute(version)
f = open("libcomps/version.cmake", "w")
f.write(version_out)
f.close()