-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpublish.py
executable file
·70 lines (63 loc) · 2.03 KB
/
publish.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 sys
import json
node_versions = {8: 57, 10: 64, 12: 72, 14: 83}
platforms = ['linux-arm', 'linux-arm64', 'linux-x64', 'darwin-x64']
release_url = 'https://github.com/bewee/macrozilla/releases/download'
license_url = 'https://raw.githubusercontent.com/bewee/macrozilla/master/LICENSE.md'
json_file = 'macrozilla.json'
release_version = sys.argv[1]
fm = open('manifest.json')
manifest = json.load(fm)
addon_id = manifest['id']
addon_name = manifest['name']
addon_description = manifest['description']
addon_author = manifest['author']
addon_homepage_url = manifest['homepage_url']
addon_primary_type = manifest['gateway_specific_settings']['webthings']['primary_type']
f = open(json_file, 'w')
f.write(
'{\n'
f' "id": "{addon_id}",\n'
f' "name": "{addon_name}",\n'
f' "description": "{addon_description}",\n'
f' "author": "{addon_author}",\n'
f' "homepage_url": "{addon_homepage_url}",\n'
f' "license_url": "{license_url}",\n'
f' "primary_type": "{addon_primary_type}",\n'
' "packages": [\n'
)
fm.close()
first_iteration = True
for node_version in node_versions:
for platform in platforms:
if first_iteration:
first_iteration = False
else:
f.write(',\n')
fc = open(f'{addon_id}-{release_version}-{platform}-v{node_version}.tgz.sha256sum', 'r')
checksum = fc.read().split(' ')[0]
fc.close()
f.write(
' {\n'
f' "architecture": "{platform}",\n'
' "language": {\n'
' "name": "nodejs",\n'
' "versions": [\n'
f' "{node_versions[node_version]}"\n'
' ]\n'
' },\n'
f' "version": "{release_version}",\n'
f' "url": "{release_url}/v{release_version}/{addon_id}-{release_version}-{platform}-v{node_version}.tgz",\n'
f' "checksum": "{checksum}",\n'
' "gateway": {\n'
' "min": "0.10.0",\n'
' "max": "*"\n'
' }\n'
' }'
)
f.write('\n')
f.write(
' ]\n'
'}\n'
)
f.close()