28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Bump all rule-engine release metadata from the workspace version."""
|
|
from pathlib import Path
|
|
import re
|
|
|
|
cargo_path = Path("Cargo.toml")
|
|
cargo = cargo_path.read_text()
|
|
match = re.search(r'(?ms)(^\[workspace\.package\]\s+.*?^version\s*=\s*")(\d+)\.(\d+)\.(\d+)(")', cargo)
|
|
if not match:
|
|
raise SystemExit("Missing [workspace.package].version")
|
|
major, minor, patch = map(int, match.group(2, 3, 4))
|
|
version = f"{major}.{minor}.{patch + 1}"
|
|
cargo_path.write_text(cargo[:match.start(2)] + version + cargo[match.end(4):])
|
|
|
|
for path, pattern in (
|
|
(Path("deploy/helm/ai-spel-rule-engine/Chart.yaml"), r'(?m)^version:\s*\d+\.\d+\.\d+\s*$'),
|
|
(Path("deploy/helm/ai-spel-rule-engine/Chart.yaml"), r'(?m)^appVersion:\s*"\d+\.\d+\.\d+"\s*$'),
|
|
(Path("deploy/argocd/application.yaml"), r'(?m)^\s+targetRevision:\s*"\d+\.\d+\.\d+"\s*$'),
|
|
):
|
|
contents = path.read_text()
|
|
if not re.search(pattern, contents):
|
|
raise SystemExit(f"Missing version field in {path}")
|
|
replacement = f'version: {version}' if pattern.startswith(r'(?m)^version') else (
|
|
f'appVersion: "{version}"' if pattern.startswith(r'(?m)^appVersion') else f' targetRevision: "{version}"'
|
|
)
|
|
path.write_text(re.sub(pattern, replacement, contents, count=1))
|
|
print(version)
|