2021-06-03 03:43:42 -06:00
|
|
|
#!/usr/bin/env python3
|
2022-06-24 05:06:16 -06:00
|
|
|
|
|
|
|
# Allow direct execution
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
|
|
|
2021-11-29 10:00:02 -07:00
|
|
|
import subprocess
|
2022-04-11 16:32:57 -06:00
|
|
|
import sys
|
|
|
|
from datetime import datetime
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2022-04-11 09:10:28 -06:00
|
|
|
with open('yt_dlp/version.py') as f:
|
2021-11-29 10:00:02 -07:00
|
|
|
exec(compile(f.read(), 'yt_dlp/version.py', 'exec'))
|
2021-01-29 10:45:27 -07:00
|
|
|
old_version = locals()['__version__']
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2021-11-29 10:00:02 -07:00
|
|
|
old_version_list = old_version.split('.')
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2021-01-29 10:45:27 -07:00
|
|
|
old_ver = '.'.join(old_version_list[:3])
|
|
|
|
old_rev = old_version_list[3] if len(old_version_list) > 3 else ''
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2021-02-16 04:24:42 -07:00
|
|
|
ver = datetime.utcnow().strftime("%Y.%m.%d")
|
2021-11-29 10:05:23 -07:00
|
|
|
|
|
|
|
rev = (sys.argv[1:] or [''])[0] # Use first argument, if present as revision number
|
|
|
|
if not rev:
|
|
|
|
rev = str(int(old_rev or 0) + 1) if old_ver == ver else ''
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2021-01-29 10:45:27 -07:00
|
|
|
VERSION = '.'.join((ver, rev)) if rev else ver
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2021-11-29 10:00:02 -07:00
|
|
|
try:
|
|
|
|
sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE)
|
|
|
|
GIT_HEAD = sp.communicate()[0].decode().strip() or None
|
|
|
|
except Exception:
|
|
|
|
GIT_HEAD = None
|
|
|
|
|
2021-12-22 18:42:26 -07:00
|
|
|
VERSION_FILE = f'''\
|
2021-11-29 10:00:02 -07:00
|
|
|
# Autogenerated by devscripts/update-version.py
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2021-11-29 10:00:02 -07:00
|
|
|
__version__ = {VERSION!r}
|
2021-01-24 13:47:37 -07:00
|
|
|
|
2021-11-29 10:00:02 -07:00
|
|
|
RELEASE_GIT_HEAD = {GIT_HEAD!r}
|
2021-12-22 18:42:26 -07:00
|
|
|
'''
|
2021-11-29 10:00:02 -07:00
|
|
|
|
|
|
|
with open('yt_dlp/version.py', 'wt') as f:
|
|
|
|
f.write(VERSION_FILE)
|
|
|
|
|
|
|
|
print('::set-output name=ytdlp_version::' + VERSION)
|
|
|
|
print(f'\nVersion = {VERSION}, Git HEAD = {GIT_HEAD}')
|