forked from KSP-RO/RP-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeMeta.py
70 lines (61 loc) · 1.87 KB
/
makeMeta.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
65
66
67
68
69
70
import os, argparse, sys, json, glob, re
class DefaultHelpParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(2)
HELP_DESC = "Creates neccesary metadata files"
parser = DefaultHelpParser(description=HELP_DESC)
parser.add_argument('tag', metavar='tag', type=str, nargs=1,
help='tag of release (e.g. 0.4.6.0')
args = parser.parse_args()
if not args.tag or len(args.tag) < 1:
print("ERROR: git tag must be specified and must be in the format major.minor.patch.build-configuration.e.g. 0.4.6.0")
sys.exit(2)
version = args.tag[0]
if version.startswith('v'):
version = version.split('v')[1]
major = int(version.split(".")[0])
minor = int(version.split(".")[1])
patch = int(version.split(".")[2])
build = int(version.split(".")[3])
# create AVC .version file
avc = {
"NAME" : "Realistic Progression One",
"URL" : "https://raw.githubusercontent.com/KSP-RO/RP-0/master/GameData/RP-0/RP-1.version",
"DOWNLOAD" : "https://github.com/KSP-RO/RP-0/releases/download/{}/RP-1-{}.zip".format(args.tag[0],args.tag[0]),
"HOMEPAGE" : "https://github.com/KSP-RO/RP-0/",
"VERSION" :
{
"MAJOR" : major,
"MINOR" : minor,
"PATCH" : patch,
"BUILD" : build
},
"KSP_VERSION" : {
"MAJOR": "1",
"MINOR": "12",
"PATCH": "3"
},
"KSP_VERSION_MIN": {
"MAJOR": "1",
"MINOR": "12",
"PATCH": "0"
},
"KSP_VERSION_MAX": {
"MAJOR": "1",
"MINOR": "12",
"PATCH": "99"
}
}
with open("RP-1.version", "w") as f:
f.write(json.dumps(avc, indent=4))
# Replace old version tag in readme
new_string = "compare/v"+version+"...master"
new_readme = []
with open("README.md", "r") as f:
for line in f.readlines():
replaced = re.sub(r'compare/v[\d|.]*...master', new_string, line)
new_readme.append(replaced)
with open("README_TEMP.md", "w") as f:
f.writelines(new_readme)