From 41bec3409d2c8a270ad11f0f222931a24c37681c Mon Sep 17 00:00:00 2001 From: Lesmiscore Date: Thu, 17 Feb 2022 16:20:14 +0900 Subject: [PATCH] add update-version.py --- devscripts/update-version.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 devscripts/update-version.py diff --git a/devscripts/update-version.py b/devscripts/update-version.py new file mode 100644 index 000000000..ce8d66ee6 --- /dev/null +++ b/devscripts/update-version.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +from datetime import datetime +import sys + + +with open('youtube_dl/version.py', 'rt') as f: + exec(compile(f.read(), 'youtube_dl/version.py', 'exec')) +old_version = locals()['__version__'] + +old_version_list = old_version.split('.') + +old_ver = '.'.join(old_version_list[:3]) +old_rev = old_version_list[3] if len(old_version_list) > 3 else '' + +ver = datetime.utcnow().strftime("%Y.%m.%d") + +rev = (sys.argv[1:] or [''])[0] # Use first argument, if present as revision number +if not rev: + rev = str(int(old_rev or 0) + 1) if old_ver == ver else '' + +VERSION = '.'.join((ver, rev)) if rev else ver + +VERSION_FILE = '''# Autogenerated by devscripts/update-version.py + +__version__ = {!r} +'''.format(VERSION) + +with open('youtube_dl/version.py', 'wt') as f: + f.write(VERSION_FILE) + +print('::set-output name=ytdl_version::' + VERSION) +print('\nVersion = %s' % VERSION)