-
Notifications
You must be signed in to change notification settings - Fork 7
/
update_releases_file.py
68 lines (58 loc) · 1.94 KB
/
update_releases_file.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
"""A script to help update the releases.json file"""
import os
import sys
import json
import argparse
def main(args):
releases_file = args.releases_file
version_file = args.version_file
base_url = args.base_url
# Get the version from the VERSION file
if os.path.exists(version_file):
with open(version_file, "r") as fh:
version = json.load(fh).get("update_server_version", "0.0.0-dev")
else:
print(f"ERROR: version file {version_file} not found!", file=sys.stderr)
exit(1)
# Get the releases from the releases file
releases = {"production": {}}
if os.path.exists(releases_file):
print(f"reading releases file - {releases_file}")
with open(releases_file, "r") as fh:
releases = json.load(fh)
# Update the releases dict with the latest version
prod = releases.get('production', {})
prod[version] = {
"fullImage": f"{base_url}/ot2-fullimage.zip",
"system": f"{base_url}/ot2-system.zip",
"version": f"{base_url}/VERSION.json",
"releaseNotes": f"{base_url}/release-notes.md",
}
releases['production'] = prod
# Save the new releases.json file
with open(releases_file, "w") as fh:
json.dump(releases, fh)
print(
f"Updated {releases_file} with - {version}: {releases['production'][version]}"
)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"-i",
"--releases-file",
help="releases.json file to update, creates it otherwise.",
)
parser.add_argument(
"-v",
"--version-file",
required=True,
help="VERSION.json file generated by the openembedded build.",
)
parser.add_argument(
"-u",
"--base-url",
required=True,
help="root url path in s3 where the output artifact files for this build are hosted.",
)
args = parser.parse_args()
main(args)