forked from blowfishpro/B9-Aerospace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.py
75 lines (61 loc) · 2.16 KB
/
release.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
71
72
73
74
75
import os
import json
import zipfile
def decode_version(file_name):
f = open(file_name, 'r')
data = json.load(f)
f.close()
version_info = data['VERSION']
major = version_info['MAJOR']
minor = version_info['MINOR']
patch = version_info['PATCH']
return '{}-{}-{}'.format(major, minor,patch)
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
module_manager_list = [file_name for file_name in os.listdir('GameData') if 'ModuleManager' in file_name]
if len(module_manager_list) == 0:
print("No ModuleManager found!")
exit(1)
elif len(module_manager_list) > 1:
print("More than one ModuleManager found:")
for file_name in module_manager_list:
print(file_name)
exit(1)
module_manager_file = 'GameData/' + module_manager_list[0]
b9_version = decode_version('GameData/B9_Aerospace/B9_Aerospace.version')
b9_legacy_version = decode_version('GameData/B9_Aerospace_Legacy/B9_Aerospace_Legacy.version')
b9_hx_version = decode_version('GameData/B9_Aerospace_HX/B9_Aerospace_HX.version')
print("Processing B9")
z = zipfile.ZipFile('B9_Aerospace_{}.zip'.format(b9_version), 'w', zipfile.ZIP_DEFLATED)
z.write('README.md')
z.write('CHANGELOG.md')
z.write(module_manager_file)
zipdir('GameData/B9_Aerospace', z)
zipdir('GameData/B9AnimationModules', z)
zipdir('GameData/B9PartSwitch', z)
zipdir('GameData/Firespitter', z)
zipdir('GameData/JSI', z)
zipdir('GameData/Klockheed_Martian_Gimbal', z)
zipdir('GameData/SmokeScreen', z)
z.close()
print("Processing B9 Legacy")
z = zipfile.ZipFile('B9_Aerospace_Legacy_{}.zip'.format(b9_legacy_version), 'w', zipfile.ZIP_DEFLATED)
z.write('README.md')
z.write('CHANGELOG.md')
zipdir('GameData/B9_Aerospace_Legacy', z)
z.close()
print("Processing B9 HX")
z = zipfile.ZipFile('B9_Aerospace_HX_{}.zip'.format(b9_version), 'w', zipfile.ZIP_DEFLATED)
z.write('README.md')
z.write('CHANGELOG.md')
z.write(module_manager_file)
zipdir('GameData/B9_Aerospace_HX', z)
zipdir('GameData/B9AnimationModules', z)
zipdir('GameData/B9PartSwitch', z)
zipdir('GameData/Klockheed_Martian_Gimbal', z)
zipdir('GameData/SmokeScreen', z)
z.close()
print("Done")