feat(bump_ver): add changelog version and date update
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
parent
372832b41d
commit
6d3e0982c9
@ -3,6 +3,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
# Base directory of the project
|
# Base directory of the project
|
||||||
BASE_DIR = Path(__file__).parent.parent
|
BASE_DIR = Path(__file__).parent.parent
|
||||||
@ -13,6 +14,7 @@ FEDORA_SPEC = BASE_DIR / "build-aux" / "fedora.spec"
|
|||||||
PYPROJECT = BASE_DIR / "pyproject.toml"
|
PYPROJECT = BASE_DIR / "pyproject.toml"
|
||||||
APP_PY = BASE_DIR / "portprotonqt" / "app.py"
|
APP_PY = BASE_DIR / "portprotonqt" / "app.py"
|
||||||
GITEA_WORKFLOW = BASE_DIR / ".gitea" / "workflows" / "build.yml"
|
GITEA_WORKFLOW = BASE_DIR / ".gitea" / "workflows" / "build.yml"
|
||||||
|
CHANGELOG = BASE_DIR / "CHANGELOG.md"
|
||||||
|
|
||||||
def bump_appimage(path: Path, old: str, new: str) -> bool:
|
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')
|
path.write_text(new_text, encoding='utf-8')
|
||||||
return bool(count)
|
return bool(count)
|
||||||
|
|
||||||
|
|
||||||
def bump_arch(path: Path, old: str, new: str) -> bool:
|
def bump_arch(path: Path, old: str, new: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Update pkgver in PKGBUILD
|
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')
|
path.write_text(new_text, encoding='utf-8')
|
||||||
return bool(count)
|
return bool(count)
|
||||||
|
|
||||||
|
|
||||||
def bump_fedora(path: Path, old: str, new: str) -> bool:
|
def bump_fedora(path: Path, old: str, new: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Update only the '%global pypi_version' line in fedora.spec
|
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')
|
path.write_text(new_text, encoding='utf-8')
|
||||||
return bool(count)
|
return bool(count)
|
||||||
|
|
||||||
|
|
||||||
def bump_pyproject(path: Path, old: str, new: str) -> bool:
|
def bump_pyproject(path: Path, old: str, new: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Update version in pyproject.toml under [project]
|
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')
|
path.write_text(new_text, encoding='utf-8')
|
||||||
return bool(count)
|
return bool(count)
|
||||||
|
|
||||||
|
|
||||||
def bump_app_py(path: Path, old: str, new: str) -> bool:
|
def bump_app_py(path: Path, old: str, new: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Update __app_version__ in app.py
|
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')
|
path.write_text(new_text, encoding='utf-8')
|
||||||
return bool(count)
|
return bool(count)
|
||||||
|
|
||||||
|
|
||||||
def bump_workflow(path: Path, old: str, new: str) -> bool:
|
def bump_workflow(path: Path, old: str, new: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Update VERSION in Gitea Actions workflow
|
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')
|
path.write_text(new_text, encoding='utf-8')
|
||||||
return bool(count)
|
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():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Bump project version in specific files')
|
parser = argparse.ArgumentParser(description='Bump project version in specific files')
|
||||||
@ -111,7 +121,8 @@ def main():
|
|||||||
(FEDORA_SPEC, bump_fedora),
|
(FEDORA_SPEC, bump_fedora),
|
||||||
(PYPROJECT, bump_pyproject),
|
(PYPROJECT, bump_pyproject),
|
||||||
(APP_PY, bump_app_py),
|
(APP_PY, bump_app_py),
|
||||||
(GITEA_WORKFLOW, bump_workflow)
|
(GITEA_WORKFLOW, bump_workflow),
|
||||||
|
(CHANGELOG, bump_changelog)
|
||||||
]
|
]
|
||||||
|
|
||||||
updated = []
|
updated = []
|
||||||
@ -126,6 +137,5 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print(f"No occurrences of version {old} found in specified files.")
|
print(f"No occurrences of version {old} found in specified files.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user