mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-11-21 04:46:31 +00:00
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>
71 lines
1.6 KiB
Python
71 lines
1.6 KiB
Python
#!/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()
|