File: update-version.py

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (23 lines) | stat: -rw-r--r-- 753 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3

import os
import re
import subprocess

tag = subprocess.run(['git', 'describe', '--tags'],
                     capture_output=True, check=True,
                     text=True).stdout.strip()
# convert v0.2.12-2-g50254a9 to 0.2.12
# test-version-exists will ensure to not include non-tagged commits
version = tag.strip("v").split('-', 1)[0]

init_path = os.path.join(os.path.dirname(__file__), '..', 'awscrt', '__init__.py')
print("Updating awscrt.__version__ to version {}".format(version))
contents = None
with open(init_path, 'r+') as init_py:
    contents = init_py.read()

contents = re.sub(r"__version__ = '[^']+'", f"__version__ = '{version}'", contents)

with open(init_path, 'w') as init_py:
    init_py.write(contents)