-
Notifications
You must be signed in to change notification settings - Fork 8
/
update_version.py
executable file
·57 lines (44 loc) · 1.73 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import os
import re
import sys
import xml.etree.ElementTree as ElementTree
if len(sys.argv) != 2:
print("Usage: ./update_version.py 0.4.2-alpha.1")
exit(1)
new_version = sys.argv[1]
new_version_components = new_version.split('.')
if len(new_version_components) < 3 or len(new_version_components) > 4:
print("""
The version number is in the wrong format
Some accepted versions:
0.3.4
0.3.4-alpha.2
0.3.4-beta.2
""")
exit(1)
def update_csharp_version(new_version):
csproj = os.path.join("pitaya-sharp", "NPitaya", "NPitaya.csproj")
tree = ElementTree.parse(csproj)
version_el = tree.getroot().find('PropertyGroup').find('PackageVersion')
current_version = version_el.text
print("Replacing {} in NPitaya.csproj for {}".format(current_version, new_version))
version_el.text = new_version
tree.write(csproj, xml_declaration=False, encoding='utf-8')
def update_unity_version(new_version):
nuspec = os.path.join("unity-example", "NPitaya.nuspec")
tree = ElementTree.parse(nuspec)
version_el = tree.getroot().find('metadata').find('version')
current_version = version_el.text
print("Replacing {} in NPitaya.nuspec for {}".format(current_version, new_version))
version_el.text = new_version
tree.write(nuspec, xml_declaration=True, encoding='utf-8')
def update_cpp_version(new_version):
version_txt = os.path.join("cpp-lib", "version.txt")
current_version = open(version_txt, "r").read()
print("Replacing {} in version.txt with {}".format(current_version, new_version))
os.unlink(version_txt)
open(version_txt, "w").write(new_version)
update_cpp_version(new_version)
update_csharp_version(new_version)
update_unity_version(new_version)