mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 11:35:25 +00:00

* fix(cargo workspace): fix cargo workspace dependencies * add bump and publish scripts * more version automation scripts
29 lines
723 B
Python
29 lines
723 B
Python
import re
|
|
|
|
|
|
WORKSPACE_CARGO_PATH = "Cargo.toml"
|
|
VERSION_RE = re.compile(r'version\s+=\s+"(\d+\.\d+\.\d+)"')
|
|
|
|
|
|
def get_version() -> str:
|
|
with open(WORKSPACE_CARGO_PATH, "r") as f:
|
|
lines = f.readlines()
|
|
l = 0
|
|
for i, line in enumerate(lines):
|
|
if line == "[dependencies]":
|
|
l = i
|
|
break
|
|
for i in range(l, len(lines)):
|
|
if lines[i].startswith("television-"):
|
|
return VERSION_RE.search(lines[i]).group(1)
|
|
return "0.0.0"
|
|
|
|
|
|
def bump_version(version: str) -> str:
|
|
major, minor, patch = version.split(".")
|
|
return f"{major}.{minor}.{int(patch) + 1}"
|
|
|
|
if __name__ == "__main__":
|
|
print(bump_version(get_version()))
|
|
|