]> jfr.im git - yt-dlp.git/blame - devscripts/update-version.py
[build] Fix MacOS Build
[yt-dlp.git] / devscripts / update-version.py
CommitLineData
cc52de43 1#!/usr/bin/env python3
915f2a92 2from datetime import datetime
36eaf303 3import subprocess
915f2a92 4
915f2a92 5
36eaf303 6with open('yt_dlp/version.py', 'rt') as f:
7 exec(compile(f.read(), 'yt_dlp/version.py', 'exec'))
e38df8f9 8old_version = locals()['__version__']
915f2a92 9
36eaf303 10old_version_list = old_version.split('.')
915f2a92 11
e38df8f9 12old_ver = '.'.join(old_version_list[:3])
13old_rev = old_version_list[3] if len(old_version_list) > 3 else ''
915f2a92 14
f3b7c693 15ver = datetime.utcnow().strftime("%Y.%m.%d")
5b328c97 16rev = str(int(old_rev or 0) + 1) if old_ver == ver else ''
915f2a92 17
e38df8f9 18VERSION = '.'.join((ver, rev)) if rev else ver
915f2a92 19
36eaf303 20try:
21 sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE)
22 GIT_HEAD = sp.communicate()[0].decode().strip() or None
23except Exception:
24 GIT_HEAD = None
25
26VERSION_FILE = f'''
27# Autogenerated by devscripts/update-version.py
915f2a92 28
36eaf303 29__version__ = {VERSION!r}
5b328c97 30
36eaf303 31RELEASE_GIT_HEAD = {GIT_HEAD!r}
32'''.lstrip()
33
34with open('yt_dlp/version.py', 'wt') as f:
35 f.write(VERSION_FILE)
36
37print('::set-output name=ytdlp_version::' + VERSION)
38print(f'\nVersion = {VERSION}, Git HEAD = {GIT_HEAD}')