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__))))
|
|
|
|
|
|
|
|
|
2022-08-08 13:38:47 -06:00
|
|
|
import contextlib
|
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-08-08 13:38:47 -06:00
|
|
|
from devscripts.utils import read_version, write_file
|
2020-09-22 19:16:06 -06:00
|
|
|
|
|
|
|
|
2022-08-08 13:38:47 -06:00
|
|
|
def get_new_version(revision):
|
|
|
|
version = datetime.utcnow().strftime('%Y.%m.%d')
|
2020-09-22 19:16:06 -06:00
|
|
|
|
2022-08-08 13:38:47 -06: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 10:05:23 -07:00
|
|
|
|
2022-08-08 13:38:47 -06:00
|
|
|
return f'{version}.{revision}' if revision else version
|
2020-09-22 19:16:06 -06:00
|
|
|
|
|
|
|
|
2022-08-08 13:38:47 -06: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 10:00:02 -07:00
|
|
|
|
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}
|
2022-07-29 09:03:01 -06:00
|
|
|
|
|
|
|
VARIANT = None
|
|
|
|
|
|
|
|
UPDATE_HINT = None
|
2021-12-22 18:42:26 -07:00
|
|
|
'''
|
2021-11-29 10:00:02 -07:00
|
|
|
|
2022-08-08 13:38:47 -06:00
|
|
|
write_file('yt_dlp/version.py', VERSION_FILE)
|
|
|
|
print(f'::set-output name=ytdlp_version::{VERSION}')
|
2021-11-29 10:00:02 -07:00
|
|
|
print(f'\nVersion = {VERSION}, Git HEAD = {GIT_HEAD}')
|