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