feat: Add function to update APP_VERSION in .env file during version sync
This commit is contained in:
parent
ad6e388dc8
commit
03c9cbe802
1 changed files with 21 additions and 0 deletions
|
|
@ -91,6 +91,26 @@ def update_env_example(version: str) -> None:
|
|||
)
|
||||
|
||||
|
||||
def update_env_file(version: str) -> None:
|
||||
"""Update APP_VERSION in .env if it exists.
|
||||
|
||||
Args:
|
||||
version: New version string to set
|
||||
"""
|
||||
env_file = PROJECT_ROOT / ".env"
|
||||
if env_file.exists():
|
||||
content = env_file.read_text()
|
||||
# Update if APP_VERSION is present
|
||||
if 'APP_VERSION=' in content:
|
||||
new_content = re.sub(
|
||||
r'APP_VERSION=[^\n]+',
|
||||
f'APP_VERSION={version}',
|
||||
content,
|
||||
)
|
||||
env_file.write_text(new_content)
|
||||
print(f"✓ Updated .env to {version}")
|
||||
|
||||
|
||||
def update_changelog(version: str) -> None:
|
||||
"""Add version header to CHANGELOG.md if not present.
|
||||
|
||||
|
|
@ -145,6 +165,7 @@ def main() -> int:
|
|||
print(f"📍 Current version from __init__.py: {version}")
|
||||
|
||||
update_env_example(version)
|
||||
update_env_file(version)
|
||||
update_changelog(version)
|
||||
print(f"\n✅ Version sync complete: {version}")
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue