2021-06-03 05:43:42 -04:00
|
|
|
#!/usr/bin/env python3
|
2022-06-24 07:06:16 -04: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 12:00:02 -05:00
|
|
|
import subprocess
|
2022-04-11 18:32:57 -04:00
|
|
|
import sys
|
|
|
|
from datetime import datetime
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2022-04-11 11:10:28 -04:00
|
|
|
with open('yt_dlp/version.py') as f:
|
2021-11-29 12:00:02 -05:00
|
|
|
exec(compile(f.read(), 'yt_dlp/version.py', 'exec'))
|
2021-01-29 12:45:27 -05:00
|
|
|
old_version = locals()['__version__']
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2021-11-29 12:00:02 -05:00
|
|
|
old_version_list = old_version.split('.')
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2021-01-29 12:45:27 -05:00
|
|
|
old_ver = '.'.join(old_version_list[:3])
|
|
|
|
old_rev = old_version_list[3] if len(old_version_list) > 3 else ''
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2021-02-16 06:24:42 -05:00
|
|
|
ver = datetime.utcnow().strftime("%Y.%m.%d")
|
2021-11-29 12:05:23 -05: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 21:16:06 -04:00
|
|
|
|
2021-01-29 12:45:27 -05:00
|
|
|
VERSION = '.'.join((ver, rev)) if rev else ver
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2021-11-29 12:00:02 -05: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 20:42:26 -05:00
|
|
|
VERSION_FILE = f'''\
|
2021-11-29 12:00:02 -05:00
|
|
|
# Autogenerated by devscripts/update-version.py
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2021-11-29 12:00:02 -05:00
|
|
|
__version__ = {VERSION!r}
|
2021-01-24 15:47:37 -05:00
|
|
|
|
2021-11-29 12:00:02 -05:00
|
|
|
RELEASE_GIT_HEAD = {GIT_HEAD!r}
|
2021-12-22 20:42:26 -05:00
|
|
|
'''
|
2021-11-29 12:00:02 -05: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}')
|