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