Skip to content

Commit 6672f73

Browse files
facontidavideclaude
andcommitted
Add create_release.py and force conda upload on conflict
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: af8736e141d0
1 parent 191680d commit 6672f73

2 files changed

Lines changed: 73 additions & 1 deletion

File tree

.github/workflows/conda.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
EXIT_CODE=0
8686
for pkg in artifacts/**/*.conda artifacts/**/*.tar.bz2; do
8787
echo "Uploading ${pkg}"
88-
if ! rattler-build upload prefix -c plotjuggler "${pkg}"; then
88+
if ! rattler-build upload prefix --force -c plotjuggler "${pkg}"; then
8989
EXIT_CODE=1
9090
fi
9191
done

create_release.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env python3
2+
"""Bump version in package.xml and conda.recipe/recipe.yaml, then commit."""
3+
4+
import argparse
5+
import re
6+
import subprocess
7+
import sys
8+
from pathlib import Path
9+
10+
REPO = Path(__file__).resolve().parent
11+
12+
VERSION_FILES = {
13+
REPO / "package.xml": (
14+
re.compile(r"(<version>)([\d.]+)(</version>)"),
15+
r"\g<1>{version}\g<3>",
16+
),
17+
REPO / "conda.recipe/recipe.yaml": (
18+
re.compile(r'(version:\s*")[\d.]+(")'),
19+
r'\g<1>{version}\2',
20+
),
21+
}
22+
23+
24+
def current_version() -> str:
25+
text = (REPO / "package.xml").read_text()
26+
m = re.search(r"<version>([\d.]+)</version>", text)
27+
if not m:
28+
sys.exit("Cannot read current version from package.xml")
29+
return m.group(1)
30+
31+
32+
def update_file(path: Path, pattern: re.Pattern, replacement: str, version: str):
33+
text = path.read_text()
34+
new_text, n = pattern.subn(replacement.format(version=version), text)
35+
if n == 0:
36+
sys.exit(f"Version pattern not found in {path.relative_to(REPO)}")
37+
path.write_text(new_text)
38+
print(f" {path.relative_to(REPO)}: updated to {version}")
39+
40+
41+
def main():
42+
cur = current_version()
43+
parser = argparse.ArgumentParser(description="Bump project version and commit.")
44+
parser.add_argument("version", help=f"New version (current: {cur})")
45+
parser.add_argument(
46+
"--no-commit", action="store_true", help="Update files without committing"
47+
)
48+
args = parser.parse_args()
49+
50+
new = args.version
51+
if new == cur:
52+
sys.exit(f"Version is already {cur}")
53+
54+
print(f"Bumping {cur}{new}")
55+
for path, (pattern, repl) in VERSION_FILES.items():
56+
update_file(path, pattern, repl, new)
57+
58+
if args.no_commit:
59+
return
60+
61+
files = [str(p) for p in VERSION_FILES]
62+
subprocess.run(["git", "add", *files], check=True, cwd=REPO)
63+
subprocess.run(
64+
["git", "commit", "-m", new],
65+
check=True,
66+
cwd=REPO,
67+
)
68+
print(f"\nCommitted as '{new}'. Review with: git log --oneline -1")
69+
70+
71+
if __name__ == "__main__":
72+
main()

0 commit comments

Comments
 (0)