You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB

  1. #!/usr/bin/env python3
  2. import json
  3. import sys
  4. import hashlib
  5. import urllib.request
  6. if len(sys.argv) <= 1:
  7. print('Specify the version number as parameter')
  8. sys.exit()
  9. version = sys.argv[1]
  10. with open('update/LATEST_VERSION', 'w') as f:
  11. f.write(version)
  12. versions_info = json.load(open('update/versions.json'))
  13. if 'signature' in versions_info:
  14. del versions_info['signature']
  15. new_version = {}
  16. filenames = {
  17. 'bin': 'youtube-dl',
  18. 'exe': 'youtube-dl.exe',
  19. 'tar': 'youtube-dl-%s.tar.gz' % version}
  20. build_dir = os.path.join('..', '..', 'build', version)
  21. for key, filename in filenames.items():
  22. fn = os.path.join(build_dir, filename)
  23. with open(fn, 'rb') as f:
  24. data = f.read()
  25. if not data:
  26. raise ValueError('File %s is empty!' % fn)
  27. sha256sum = hashlib.sha256(data).hexdigest()
  28. new_version[key] = (url, sha256sum)
  29. versions_info['versions'][version] = new_version
  30. versions_info['latest'] = version
  31. with open('update/versions.json', 'w') as jsonf:
  32. json.dump(versions_info, jsonf, indent=4, sort_keys=True)