forked from gooddata/gooddata-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbump_version.py
More file actions
34 lines (28 loc) · 992 Bytes
/
Copy pathbump_version.py
File metadata and controls
34 lines (28 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# (C) 2023 GoodData Corporation
import sys
from pathlib import Path
import tomllib
_ROOT_DIR = Path(__file__).resolve().parent.parent
def get_version(content: dict) -> list[int]:
current_version = content.get("tool", {}).get("tbump", {}).get("version", {}).get("current")
if current_version is None:
raise ValueError("No current version found while reading from pyproject.toml")
return list(map(int, current_version.split(".")))
if __name__ == "__main__":
bump_type = sys.argv[1]
with open(_ROOT_DIR / "pyproject.toml", "rb") as f:
data = tomllib.load(f)
version = get_version(data)
match bump_type:
case "patch":
version[2] += 1
case "minor":
version[1] += 1
version[2] = 0
case "major":
version[0] += 1
version[1] = 0
version[2] = 0
case _:
raise ValueError("Invalid bump type")
print(".".join(list(map(str, version))))