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