This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsetVersion.py
55 lines (37 loc) · 1.53 KB
/
setVersion.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
#sets the version in the VersionInfo.cs file and the .version file
import sys
import json
VersionInfo = "./ScrapYard/Properties/VersionInfo.cs"
VersionFile = "./GameData/ScrapYard/ScrapYard.version"
with open(VersionFile, 'r') as v:
fileJSON = json.load(v)
#get the various parts of the version from the passed in version
#version = sys.argv[1] #"1.2.3.4" or "major.minor.patch.build"
#versionSplit = version.split('.')
#major = int(versionSplit[0])
#minor = int(versionSplit[1])
#patch = int(versionSplit[2])
#build = int(versionSplit[3])
build = sys.argv[1]
major = fileJSON["VERSION"]["MAJOR"]
minor = fileJSON["VERSION"]["MINOR"]
patch = fileJSON["VERSION"]["PATCH"]
version = '{0}.{1}.{2}.{3}'.format(major, minor, patch, build)
print('Version is '+version)
#update the VersionInfo.cs file
print("Setting .dll version")
with open(VersionInfo, 'w') as v:
#v.write('[assembly: System.Reflection.AssemblyVersion("' + version + '")] //Added by build\n')
v.write('[assembly: System.Reflection.AssemblyFileVersion("' + version + '")] //Added by build\n')
v.write('[assembly: System.Reflection.AssemblyInformationalVersion("' + version + '")] //Added by build\n')
#Update the .version file
#don't erase everything, just the version stuff
#it's json, so lets do it that way
print("Editing .version file")
fileJSON["VERSION"]["BUILD"] = build
with open(VersionFile, 'w') as v:
json.dump(fileJSON, v, sort_keys=True, indent=4)
print("Writing version.txt")
with open('version.txt', 'w') as f:
f.write(version+'\n')
print("Done!")