-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_version.py
More file actions
executable file
·47 lines (37 loc) · 1.3 KB
/
update_version.py
File metadata and controls
executable file
·47 lines (37 loc) · 1.3 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "tomli",
# ]
# ///
"""
Script to ensure version consistency between pyproject.toml and __init__.py.
Run this script after release-please updates the version in pyproject.toml.
"""
import re
import subprocess
from pathlib import Path
import tomli
def main() -> None:
"""Update version in __init__.py to match pyproject.toml and refresh uv.lock."""
# Read version from pyproject.toml
pyproject_path = Path("pyproject.toml")
init_path = Path("stackone_ai/__init__.py")
with open(pyproject_path, "rb") as f:
pyproject = tomli.load(f)
version = pyproject["project"]["version"]
# Update version in __init__.py
init_content = init_path.read_text()
new_init_content = re.sub(r'__version__ = "[^"]+"', f'__version__ = "{version}"', init_content)
if init_content != new_init_content:
init_path.write_text(new_init_content)
print(f"Updated version in {init_path} to {version}")
else:
print(f"Version in {init_path} already matches {version}")
# Update uv.lock to reflect version change in pyproject.toml
print("Updating uv.lock...")
subprocess.run(["uv", "lock"], check=True)
print("uv.lock updated successfully")
if __name__ == "__main__":
main()