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