chore: Update version to 0.5.0 in project files and enhance version update script
This commit is contained in:
parent
aa7db1a3ab
commit
5dfb96874e
3 changed files with 12 additions and 8 deletions
|
|
@ -31,20 +31,22 @@ def validate_version(version: str) -> bool:
|
|||
return bool(re.match(pattern, version))
|
||||
|
||||
|
||||
def update_file(file_path: Path, old_pattern: str, new_version: str) -> bool:
|
||||
def update_file(file_path: Path, old_pattern: str, new_version: str, multiline: bool = False) -> bool:
|
||||
"""Update version in a file.
|
||||
|
||||
Args:
|
||||
file_path: Path to file to update
|
||||
old_pattern: Regex pattern to find version
|
||||
new_version: New version string
|
||||
multiline: Whether to use multiline mode for regex
|
||||
|
||||
Returns:
|
||||
True if successful, False otherwise
|
||||
"""
|
||||
try:
|
||||
content = file_path.read_text()
|
||||
updated_content = re.sub(old_pattern, new_version, content)
|
||||
flags = re.MULTILINE if multiline else 0
|
||||
updated_content = re.sub(old_pattern, new_version, content, flags=flags)
|
||||
|
||||
if content == updated_content:
|
||||
print(f"✓ {file_path.name} already up-to-date")
|
||||
|
|
@ -89,11 +91,13 @@ def main() -> int:
|
|||
|
||||
# Update pyproject.toml
|
||||
if pyproject_path.exists():
|
||||
pattern = r'version = "[^"]+"'
|
||||
# Use word boundary to match 'version' but not 'python_version'
|
||||
pattern = r'^version = "[^"]+"'
|
||||
success &= update_file(
|
||||
pyproject_path,
|
||||
pattern,
|
||||
f'version = "{new_version}"'
|
||||
f'version = "{new_version}"',
|
||||
multiline=True
|
||||
)
|
||||
else:
|
||||
print(f"✗ {pyproject_path} not found")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue