From 5b328c97d78e69b3cdac558696e0913e267ec226 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 25 Jan 2021 02:17:37 +0530 Subject: [PATCH] Changed revision number to use '.' instead of '-' and refactor it :ci skip dl --- scripts/update-version-workflow.py | 33 ++++++++---------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/scripts/update-version-workflow.py b/scripts/update-version-workflow.py index cebcbf1b4..bb3d8c83e 100644 --- a/scripts/update-version-workflow.py +++ b/scripts/update-version-workflow.py @@ -1,44 +1,27 @@ from __future__ import unicode_literals from datetime import datetime -# import urllib.request - -# response = urllib.request.urlopen('https://blackjack4494.github.io/youtube-dlc/update/LATEST_VERSION') -# _LATEST_VERSION = response.read().decode('utf-8') exec(compile(open('youtube_dlc/version.py').read(), 'youtube_dlc/version.py', 'exec')) _LATEST_VERSION = locals()['__version__'] -_OLD_VERSION = _LATEST_VERSION.rsplit("-", 1) +_OLD_VERSION = _LATEST_VERSION.replace('-', '.').split(".", 4) -if len(_OLD_VERSION) > 0: - old_ver = _OLD_VERSION[0] +old_ver = '.'.join(_OLD_VERSION[:3]) +old_rev = _OLD_VERSION[3] if len(_OLD_VERSION) > 3 else '' -old_rev = '' -if len(_OLD_VERSION) > 1: - old_rev = _OLD_VERSION[1] +ver = datetime.now().strftime("%Y.%m.%d") +rev = str(int(old_rev or 0) + 1) if old_ver == ver else '' -now = datetime.now() -# ver = f'{datetime.today():%Y.%m.%d}' -ver = now.strftime("%Y.%m.%d") -rev = '' - -if old_ver == ver: - if old_rev: - rev = int(old_rev) + 1 - else: - rev = 1 - -_SEPARATOR = '-' - -version = _SEPARATOR.join(filter(None, [ver, str(rev)])) +version = '.'.join((ver, rev)) if rev else ver print('::set-output name=ytdlc_version::' + version) file_version_py = open('youtube_dlc/version.py', 'rt') data = file_version_py.read() -data = data.replace(locals()['__version__'], version) +data = data.replace(_LATEST_VERSION, version) file_version_py.close() + file_version_py = open('youtube_dlc/version.py', 'wt') file_version_py.write(data) file_version_py.close()