From 90a419538128b54fbd30da4b8a8088ac59f8c691 Mon Sep 17 00:00:00 2001 From: Fahad Date: Wed, 20 Aug 2025 16:25:43 +0400 Subject: [PATCH] fix: establish version 5.8.6 and add version sync automation - Set version to 5.8.6 in pyproject.toml to match config.py - Add automatic version sync script for GitHub Actions - Configure semantic-release for proper version tracking - Ensure __updated__ field auto-updates with each release --- pyproject.toml | 3 +++ scripts/sync_version.py | 29 +++++++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 46158cc..f2cfb8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,6 +87,9 @@ ignore = [ [tool.semantic_release] version_toml = ["pyproject.toml:project.version"] branch = "main" +version_source = "tag" +version_pattern = "v(?P\d+)\.(?P\d+)\.(?P\d+)" +major_on_zero = false build_command = "python -m pip install --upgrade build && python -m build" dist_path = "dist/" upload_to_vcs_release = true diff --git a/scripts/sync_version.py b/scripts/sync_version.py index d2e33fd..c582713 100755 --- a/scripts/sync_version.py +++ b/scripts/sync_version.py @@ -6,40 +6,33 @@ This script is called by GitHub Actions after semantic-release updates the versi import re from datetime import datetime + import toml def update_config_version(): # Read version from pyproject.toml - with open("pyproject.toml", "r") as f: + with open("pyproject.toml") as f: data = toml.load(f) version = data["project"]["version"] - + # Read current config.py - with open("config.py", "r") as f: + with open("config.py") as f: content = f.read() - + # Update version - content = re.sub( - r'__version__ = "[^"]*"', - f'__version__ = "{version}"', - content - ) - + content = re.sub(r'__version__ = "[^"]*"', f'__version__ = "{version}"', content) + # Update date to current date today = datetime.now().strftime("%Y-%m-%d") - content = re.sub( - r'__updated__ = "[^"]*"', - f'__updated__ = "{today}"', - content - ) - + content = re.sub(r'__updated__ = "[^"]*"', f'__updated__ = "{today}"', content) + # Write back with open("config.py", "w") as f: f.write(content) - + print(f"Updated config.py to version {version}") if __name__ == "__main__": - update_config_version() \ No newline at end of file + update_config_version()