]> jfr.im git - yt-dlp.git/blame - scripts/update-version-workflow.py
update workflow, semi fix integrated updater
[yt-dlp.git] / scripts / update-version-workflow.py
CommitLineData
915f2a92
U
1from 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
7exec(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
13if len(_OLD_VERSION) > 0:
14 old_ver = _OLD_VERSION[0]
15
16old_rev = ''
17if len(_OLD_VERSION) > 1:
18 old_rev = _OLD_VERSION[1]
19
20ver = f'{datetime.today():%Y.%m.%d}'
21rev = ''
22
23if old_ver == ver:
24 if old_rev:
25 rev = int(old_rev) + 1
26 else:
27 rev = 1
28
29_SEPARATOR = '-'
30
31version = _SEPARATOR.join(filter(None, [ver, str(rev)]))
32
33print('::set-output name=ydlc_version::' + version)
34
35file_version_py = open('youtube_dlc/version.py', 'rt')
36data = file_version_py.read()
37data = data.replace(locals()['__version__'], version)
38file_version_py.close()
39file_version_py = open('youtube_dlc/version.py', 'wt')
40file_version_py.write(data)
41file_version_py.close()