]> jfr.im git - yt-dlp.git/blob - scripts/update-version-workflow.py
Merge remote-tracking branch 'origin/master'
[yt-dlp.git] / scripts / update-version-workflow.py
1 from __future__ import unicode_literals
2 from datetime import datetime
3 # import urllib.request
4
5 # response = urllib.request.urlopen('https://blackjack4494.github.io/youtube-dlc/update/LATEST_VERSION')
6 # _LATEST_VERSION = response.read().decode('utf-8')
7
8 exec(compile(open('youtube_dlc/version.py').read(), 'youtube_dlc/version.py', 'exec'))
9
10 _LATEST_VERSION = locals()['__version__']
11
12 _OLD_VERSION = _LATEST_VERSION.rsplit("-", 1)
13
14 if len(_OLD_VERSION) > 0:
15 old_ver = _OLD_VERSION[0]
16
17 old_rev = ''
18 if len(_OLD_VERSION) > 1:
19 old_rev = _OLD_VERSION[1]
20
21 now = datetime.now()
22 # ver = f'{datetime.today():%Y.%m.%d}'
23 ver = now.strftime("%Y.%m.%d")
24 rev = ''
25
26 if old_ver == ver:
27 if old_rev:
28 rev = int(old_rev) + 1
29 else:
30 rev = 1
31
32 _SEPARATOR = '-'
33
34 version = _SEPARATOR.join(filter(None, [ver, str(rev)]))
35
36 print('::set-output name=ytdlc_version::' + version)
37
38 file_version_py = open('youtube_dlc/version.py', 'rt')
39 data = file_version_py.read()
40 data = data.replace(locals()['__version__'], version)
41 file_version_py.close()
42 file_version_py = open('youtube_dlc/version.py', 'wt')
43 file_version_py.write(data)
44 file_version_py.close()