]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
54007a45 | 2 | |
3 | # Allow direct execution | |
4 | import os | |
5 | import sys | |
6 | ||
7 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
8 | ||
9 | ||
36eaf303 | 10 | import subprocess |
f8271158 | 11 | import sys |
12 | from datetime import datetime | |
915f2a92 | 13 | |
86e5f3ed | 14 | with open('yt_dlp/version.py') as f: |
36eaf303 | 15 | exec(compile(f.read(), 'yt_dlp/version.py', 'exec')) |
e38df8f9 | 16 | old_version = locals()['__version__'] |
915f2a92 | 17 | |
36eaf303 | 18 | old_version_list = old_version.split('.') |
915f2a92 | 19 | |
e38df8f9 | 20 | old_ver = '.'.join(old_version_list[:3]) |
21 | old_rev = old_version_list[3] if len(old_version_list) > 3 else '' | |
915f2a92 | 22 | |
f3b7c693 | 23 | ver = datetime.utcnow().strftime("%Y.%m.%d") |
75b725a7 | 24 | |
25 | rev = (sys.argv[1:] or [''])[0] # Use first argument, if present as revision number | |
26 | if not rev: | |
27 | rev = str(int(old_rev or 0) + 1) if old_ver == ver else '' | |
915f2a92 | 28 | |
e38df8f9 | 29 | VERSION = '.'.join((ver, rev)) if rev else ver |
915f2a92 | 30 | |
36eaf303 | 31 | try: |
32 | sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE) | |
33 | GIT_HEAD = sp.communicate()[0].decode().strip() or None | |
34 | except Exception: | |
35 | GIT_HEAD = None | |
36 | ||
b69fd25c | 37 | VERSION_FILE = f'''\ |
36eaf303 | 38 | # Autogenerated by devscripts/update-version.py |
915f2a92 | 39 | |
36eaf303 | 40 | __version__ = {VERSION!r} |
5b328c97 | 41 | |
36eaf303 | 42 | RELEASE_GIT_HEAD = {GIT_HEAD!r} |
b69fd25c | 43 | ''' |
36eaf303 | 44 | |
45 | with open('yt_dlp/version.py', 'wt') as f: | |
46 | f.write(VERSION_FILE) | |
47 | ||
48 | print('::set-output name=ytdlp_version::' + VERSION) | |
49 | print(f'\nVersion = {VERSION}, Git HEAD = {GIT_HEAD}') |