chore: automate development version and release generation (#772)
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled

This change introduces a GitHub Action to automate release creation, including
proper tagging and automatic addition of a development marker to the version.

A hash is also appended to development versions to make their state easier to
distinguish.

Tests and release documentation have been updated to reflect the revised
release workflow. Several files now retrieve the current version dynamically.

The test --full-run option has been rename to --finalize to make
clear it is to do commit finalization testing.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2025-11-20 00:10:19 +01:00
committed by GitHub
parent bdbb0b060d
commit 976a2c8405
28 changed files with 762 additions and 448 deletions

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""
Update VERSION_BASE in version.py after a release tag.
Behavior:
- Read VERSION_BASE from version.py
- Strip ANY existing "+dev" suffix
- Append exactly one "+dev"
- Write back the updated file
This ensures:
0.2.0 --> 0.2.0+dev
0.2.0+dev --> 0.2.0+dev
0.2.0+dev+dev -> 0.2.0+dev
"""
import re
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
VERSION_FILE = ROOT / "src" / "akkudoktoreos" / "core" / "version.py"
def bump_dev_version_file(file: Path) -> str:
text = file.read_text(encoding="utf-8")
# Extract current version
m = re.search(r'^VERSION_BASE\s*=\s*["\']([^"\']+)["\']',
text, flags=re.MULTILINE)
if not m:
raise ValueError("VERSION_BASE not found")
base_version = m.group(1)
# Remove trailing +dev if present → ensure idempotency
cleaned = re.sub(r'(\+dev)+$', '', base_version)
# Append +dev
new_version = f"{cleaned}+dev"
# Replace inside file content
new_text = re.sub(
r'^VERSION_BASE\s*=\s*["\']([^"\']+)["\']',
f'VERSION_BASE = "{new_version}"',
text,
flags=re.MULTILINE
)
file.write_text(new_text, encoding="utf-8")
return new_version
def main():
# Use CLI argument or fallback default path
version_file = Path(sys.argv[1]) if len(sys.argv) > 1 else VERSION_FILE
try:
new_version = bump_dev_version_file(version_file)
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
# MUST print to stdout
print(new_version)
if __name__ == "__main__":
main()