]> Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/gh-pages/add-version.py
Annotate changelog with bugs closed.
[youtubedl] / devscripts / gh-pages / add-version.py
1 #!/usr/bin/env python3
2
3 import json
4 import sys
5 import hashlib
6 import os.path
7
8
9 if len(sys.argv) <= 1:
10 print('Specify the version number as parameter')
11 sys.exit()
12 version = sys.argv[1]
13
14 with open('update/LATEST_VERSION', 'w') as f:
15 f.write(version)
16
17 versions_info = json.load(open('update/versions.json'))
18 if 'signature' in versions_info:
19 del versions_info['signature']
20
21 new_version = {}
22
23 filenames = {
24 'bin': 'youtube-dl',
25 'exe': 'youtube-dl.exe',
26 'tar': 'youtube-dl-%s.tar.gz' % version}
27 build_dir = os.path.join('..', '..', 'build', version)
28 for key, filename in filenames.items():
29 url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
30 fn = os.path.join(build_dir, filename)
31 with open(fn, 'rb') as f:
32 data = f.read()
33 if not data:
34 raise ValueError('File %s is empty!' % fn)
35 sha256sum = hashlib.sha256(data).hexdigest()
36 new_version[key] = (url, sha256sum)
37
38 versions_info['versions'][version] = new_version
39 versions_info['latest'] = version
40
41 with open('update/versions.json', 'w') as jsonf:
42 json.dump(versions_info, jsonf, indent=4, sort_keys=True)