From 6d3e0982c9f88be9728844dbe44c6aac96c63fcb Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Wed, 4 Jun 2025 20:40:25 +0500 Subject: [PATCH] feat(bump_ver): add changelog version and date update Signed-off-by: Boris Yumankulov --- dev-scripts/bump_ver.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/dev-scripts/bump_ver.py b/dev-scripts/bump_ver.py index 851fcc0..40f2d94 100755 --- a/dev-scripts/bump_ver.py +++ b/dev-scripts/bump_ver.py @@ -3,6 +3,7 @@ import argparse import re from pathlib import Path +from datetime import date # Base directory of the project BASE_DIR = Path(__file__).parent.parent @@ -13,6 +14,7 @@ FEDORA_SPEC = BASE_DIR / "build-aux" / "fedora.spec" PYPROJECT = BASE_DIR / "pyproject.toml" APP_PY = BASE_DIR / "portprotonqt" / "app.py" GITEA_WORKFLOW = BASE_DIR / ".gitea" / "workflows" / "build.yml" +CHANGELOG = BASE_DIR / "CHANGELOG.md" def bump_appimage(path: Path, old: str, new: str) -> bool: """ @@ -27,7 +29,6 @@ def bump_appimage(path: Path, old: str, new: str) -> bool: path.write_text(new_text, encoding='utf-8') return bool(count) - def bump_arch(path: Path, old: str, new: str) -> bool: """ Update pkgver in PKGBUILD @@ -41,7 +42,6 @@ def bump_arch(path: Path, old: str, new: str) -> bool: path.write_text(new_text, encoding='utf-8') return bool(count) - def bump_fedora(path: Path, old: str, new: str) -> bool: """ Update only the '%global pypi_version' line in fedora.spec @@ -55,7 +55,6 @@ def bump_fedora(path: Path, old: str, new: str) -> bool: path.write_text(new_text, encoding='utf-8') return bool(count) - def bump_pyproject(path: Path, old: str, new: str) -> bool: """ Update version in pyproject.toml under [project] @@ -69,7 +68,6 @@ def bump_pyproject(path: Path, old: str, new: str) -> bool: path.write_text(new_text, encoding='utf-8') return bool(count) - def bump_app_py(path: Path, old: str, new: str) -> bool: """ Update __app_version__ in app.py @@ -83,7 +81,6 @@ def bump_app_py(path: Path, old: str, new: str) -> bool: path.write_text(new_text, encoding='utf-8') return bool(count) - def bump_workflow(path: Path, old: str, new: str) -> bool: """ Update VERSION in Gitea Actions workflow @@ -97,6 +94,19 @@ def bump_workflow(path: Path, old: str, new: str) -> bool: path.write_text(new_text, encoding='utf-8') return bool(count) +def bump_changelog(path: Path, old: str, new: str) -> bool: + """ + Update [Unreleased] to [new] - YYYY-MM-DD in CHANGELOG.md + """ + if not path.exists(): + return False + text = path.read_text(encoding='utf-8') + pattern = re.compile(r"(?m)^##\s*\[Unreleased\]$") + current_date = date.today().strftime('%Y-%m-%d') + new_text, count = pattern.subn(f"## [{new}] - {current_date}", text) + if count: + path.write_text(new_text, encoding='utf-8') + return bool(count) def main(): parser = argparse.ArgumentParser(description='Bump project version in specific files') @@ -111,7 +121,8 @@ def main(): (FEDORA_SPEC, bump_fedora), (PYPROJECT, bump_pyproject), (APP_PY, bump_app_py), - (GITEA_WORKFLOW, bump_workflow) + (GITEA_WORKFLOW, bump_workflow), + (CHANGELOG, bump_changelog) ] updated = [] @@ -126,6 +137,5 @@ def main(): else: print(f"No occurrences of version {old} found in specified files.") - if __name__ == '__main__': main()