-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_release.py
50 lines (43 loc) · 1.43 KB
/
create_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
import datetime
import json
from collections import OrderedDict
import os
import zipfile
import copy
def createRelease():
version = today_version()
manifest_content = read_manifest()
create_versioned_manifest(copy.deepcopy(manifest_content), version)
create_zip_file(version)
clean_up(manifest_content)
def today_version():
return '{dt.year}.{dt.month}.{dt.day}'.format(dt = datetime.datetime.now())
def read_manifest():
in_file = open('manifest.json', 'r')
manifest_content = json.loads(in_file.read(), object_pairs_hook=OrderedDict)
in_file.close()
return manifest_content
def create_versioned_manifest(manifest_content, version):
manifest_content['version'] = version
manifest_json = json.dumps(manifest_content, indent=4, separators=(',', ': '))
out_file = open('manifest.json', 'w')
out_file.write(manifest_json)
out_file.close()
def create_zip_file(version):
zip_file_name = 'cleanHomescreenAddon_' + version + '.zip'
print("creating release package " + zip_file_name)
zip_file = zipfile.ZipFile(zip_file_name, 'w')
file_names = ["manifest.json",
"cleanHomescreen.js",
"icon/128.png",
"icon/512.png"]
for file_name in file_names:
zip_file.write(file_name)
zip_file.close()
def clean_up(manifest_content):
out_file = open('manifest.json', 'w')
manifest_json = json.dumps(manifest_content, indent=4, separators=(',', ': '))
out_file.write(manifest_json)
out_file.close()
if __name__ == '__main__':
createRelease()