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__))))
|
|
|
|
|
|
|
|
|
2022-08-08 15:38:47 -04:00
|
|
|
import contextlib
|
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-08-08 15:38:47 -04:00
|
|
|
from devscripts.utils import read_version, write_file
|
2020-09-22 21:16:06 -04:00
|
|
|
|
|
|
|
|
2022-08-08 15:38:47 -04:00
|
|
|
def get_new_version(revision):
|
|
|
|
version = datetime.utcnow().strftime('%Y.%m.%d')
|
2020-09-22 21:16:06 -04:00
|
|
|
|
2022-08-08 15:38:47 -04:00
|
|
|
if revision:
|
|
|
|
assert revision.isdigit(), 'Revision must be a number'
|
|
|
|
else:
|
|
|
|
old_version = read_version().split('.')
|
|
|
|
if version.split('.') == old_version[:3]:
|
|
|
|
revision = str(int((old_version + [0])[3]) + 1)
|
2021-11-29 12:05:23 -05:00
|
|
|
|
2022-08-08 15:38:47 -04:00
|
|
|
return f'{version}.{revision}' if revision else version
|
2020-09-22 21:16:06 -04:00
|
|
|
|
|
|
|
|
2022-08-08 15:38:47 -04:00
|
|
|
def get_git_head():
|
|
|
|
with contextlib.suppress(Exception):
|
|
|
|
sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE)
|
|
|
|
return sp.communicate()[0].decode().strip() or None
|
|
|
|
|
|
|
|
|
|
|
|
VERSION = get_new_version((sys.argv + [''])[1])
|
|
|
|
GIT_HEAD = get_git_head()
|
2021-11-29 12:00:02 -05:00
|
|
|
|
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}
|
2022-07-29 11:03:01 -04:00
|
|
|
|
|
|
|
VARIANT = None
|
|
|
|
|
|
|
|
UPDATE_HINT = None
|
2021-12-22 20:42:26 -05:00
|
|
|
'''
|
2021-11-29 12:00:02 -05:00
|
|
|
|
2022-08-08 15:38:47 -04:00
|
|
|
write_file('yt_dlp/version.py', VERSION_FILE)
|
|
|
|
print(f'::set-output name=ytdlp_version::{VERSION}')
|
2021-11-29 12:00:02 -05:00
|
|
|
print(f'\nVersion = {VERSION}, Git HEAD = {GIT_HEAD}')
|