|
1 | 1 | #!/usr/bin/env python3 |
2 | | -import tomllib |
3 | 2 | import subprocess |
4 | 3 |
|
5 | | -import tomli_w |
6 | | - |
7 | | - |
8 | | -def bump_version(version: str) -> str: |
9 | | - splitted_version = version.split(".") |
10 | | - bumped_version = int(splitted_version[-1]) + 1 |
11 | | - splitted_version[-1] = str(bumped_version) |
12 | | - return ".".join(splitted_version) |
13 | | - |
14 | 4 |
|
15 | 5 | def main() -> None: |
16 | | - with open("uv.lock", "rb") as fd: |
17 | | - data = tomllib.load(fd) |
18 | | - |
19 | | - package = next(p for p in data["package"] if p["name"] == "edit-python-pe") |
20 | | - |
21 | | - version = bump_version(package["version"]) |
22 | | - |
23 | | - package["version"] = version |
24 | | - |
25 | | - with open("uv.lock", "wb") as fd: |
26 | | - tomli_w.dump(data, fd) |
27 | | - |
28 | | - with open("pyproject.toml", "rb") as fd: |
29 | | - data = tomllib.load(fd) |
30 | | - |
31 | | - data["project"]["version"] = package["version"] |
32 | | - |
33 | | - with open("pyproject.toml", "wb") as fd: |
34 | | - tomli_w.dump(data, fd) |
35 | | - |
| 6 | + subprocess.run(["uv", "version", "--bump", "patch"]) |
| 7 | + result = subprocess.run( |
| 8 | + ["uv", "version", "--short"], stdout=subprocess.PIPE, encoding="utf-8" |
| 9 | + ) |
| 10 | + version = result.stdout.strip() |
36 | 11 | subprocess.run(["git", "add", "uv.lock"]) |
37 | 12 | subprocess.run(["git", "add", "pyproject.toml"]) |
38 | 13 | subprocess.run(["git", "commit", "-m", f"bump version to {version}"]) |
|
0 commit comments