]> jfr.im git - yt-dlp.git/blame - devscripts/update-version-workflow.py
Linter and misc cleanup
[yt-dlp.git] / devscripts / update-version-workflow.py
CommitLineData
f940c317 1from __future__ import unicode_literals
915f2a92 2from datetime import datetime
66c935fb 3# import urllib.request
915f2a92 4
66c935fb 5# response = urllib.request.urlopen('https://blackjack4494.github.io/youtube-dlc/update/LATEST_VERSION')
6# _LATEST_VERSION = response.read().decode('utf-8')
915f2a92 7
66c935fb 8exec(compile(open('youtube_dlc/version.py').read(), 'youtube_dlc/version.py', 'exec'))
915f2a92
U
9_LATEST_VERSION = locals()['__version__']
10
5b328c97 11_OLD_VERSION = _LATEST_VERSION.replace('-', '.').split(".", 4)
915f2a92 12
5b328c97 13old_ver = '.'.join(_OLD_VERSION[:3])
14old_rev = _OLD_VERSION[3] if len(_OLD_VERSION) > 3 else ''
915f2a92 15
5b328c97 16ver = datetime.now().strftime("%Y.%m.%d")
17rev = str(int(old_rev or 0) + 1) if old_ver == ver else ''
915f2a92 18
5b328c97 19version = '.'.join((ver, rev)) if rev else ver
915f2a92 20
afe4cdcf 21print('::set-output name=ytdlc_version::' + version)
915f2a92
U
22
23file_version_py = open('youtube_dlc/version.py', 'rt')
24data = file_version_py.read()
5b328c97 25data = data.replace(_LATEST_VERSION, version)
915f2a92 26file_version_py.close()
5b328c97 27
915f2a92
U
28file_version_py = open('youtube_dlc/version.py', 'wt')
29file_version_py.write(data)
30file_version_py.close()