Skip to content

Commit d3ceeaf

Browse files
committed
chore: bump diracx-charts versions when new release
1 parent 27a6b8d commit d3ceeaf

2 files changed

Lines changed: 148 additions & 1 deletion

File tree

.github/workflows/deployment.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,61 @@ jobs:
150150
context: .
151151
push: true
152152
tags: ghcr.io/diracgrid/diracx-web/static:${{ needs.release-please.outputs.tag_name }}
153-
platforms: linux/amd64,linux/arm64
153+
platforms: linux/amd64,linux/arm64
154+
155+
# Helm charts are updated in diracx-charts
156+
# -----------------------------------------
157+
158+
update-charts:
159+
name: Update Helm charts
160+
needs:
161+
- release-please
162+
- build-deploy-diracx-web-release-image
163+
runs-on: ubuntu-latest
164+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
165+
steps:
166+
- name: Checkout diracx-web (for update script)
167+
uses: actions/checkout@v6
168+
with:
169+
path: diracx-web
170+
sparse-checkout: .github/workflows
171+
172+
- name: Checkout diracx-charts
173+
uses: actions/checkout@v6
174+
with:
175+
repository: DIRACGrid/diracx-charts
176+
token: ${{ secrets.CHARTS_UPDATE_TOKEN }}
177+
path: diracx-charts
178+
179+
- name: Configure Git
180+
run: |
181+
cd diracx-charts
182+
git config user.name "github-actions[bot]"
183+
git config user.email "github-actions[bot]@users.noreply.github.com"
184+
185+
- name: Update chart versions
186+
run: |
187+
python diracx-web/.github/workflows/update_chart_version.py \
188+
--charts-dir diracx-charts \
189+
--web-version "${{ needs.release-please.outputs.tag_name }}"
190+
191+
- name: Install pre-commit
192+
run: pip install pre-commit
193+
194+
- name: Run pre-commit to update README
195+
run: |
196+
cd diracx-charts
197+
pre-commit run --all-files || true
198+
199+
- name: Commit and push changes
200+
if: success()
201+
run: |
202+
cd diracx-charts
203+
git add -A
204+
205+
if ! git diff --cached --quiet; then
206+
git commit -m "chore: bump diracx-web to ${{ needs.release-please.outputs.tag_name }}"
207+
git push origin master
208+
else
209+
echo "No changes to commit"
210+
fi
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env python3
2+
"""Update diracx-charts with a new diracx-web version.
3+
4+
Bumps the chart version and updates the web image tag in values.yaml.
5+
Does NOT modify appVersion (that tracks the diracx server version).
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import argparse
11+
import re
12+
import sys
13+
from pathlib import Path
14+
15+
16+
def bump_version(current_version: str) -> str:
17+
"""Bump a version: increment alpha number if present, otherwise patch."""
18+
match = re.match(
19+
r"^(\d+\.\d+\.\d+)-alpha\.(\d+)$", current_version
20+
)
21+
if match:
22+
base, alpha = match.group(1), int(match.group(2))
23+
return f"{base}-alpha.{alpha + 1}"
24+
25+
match = re.match(r"^(\d+)\.(\d+)\.(\d+)$", current_version)
26+
if match:
27+
major, minor, patch = match.groups()
28+
return f"{major}.{minor}.{int(patch) + 1}"
29+
30+
raise ValueError(f"Invalid version format: {current_version}")
31+
32+
33+
def main() -> None:
34+
parser = argparse.ArgumentParser(
35+
description="Update diracx-charts for a new diracx-web release"
36+
)
37+
parser.add_argument(
38+
"--charts-dir",
39+
type=Path,
40+
required=True,
41+
help="Path to the diracx-charts repository",
42+
)
43+
parser.add_argument(
44+
"--web-version",
45+
required=True,
46+
help="New diracx-web version (e.g., v0.1.0)",
47+
)
48+
args = parser.parse_args()
49+
50+
chart_yaml = args.charts_dir / "diracx" / "Chart.yaml"
51+
values_yaml = args.charts_dir / "diracx" / "values.yaml"
52+
53+
for path in (chart_yaml, values_yaml):
54+
if not path.exists():
55+
print(f"Error: {path} not found")
56+
sys.exit(1)
57+
58+
# Read and bump chart version
59+
chart_content = chart_yaml.read_text()
60+
version_match = re.search(r'^version:\s*"?([^"\n]+)"?', chart_content, re.MULTILINE)
61+
if not version_match:
62+
print("Error: could not find version in Chart.yaml")
63+
sys.exit(1)
64+
65+
current_chart_version = version_match.group(1)
66+
new_chart_version = bump_version(current_chart_version)
67+
68+
chart_content = re.sub(
69+
r'^version:\s*.*$',
70+
f'version: "{new_chart_version}"',
71+
chart_content,
72+
flags=re.MULTILINE,
73+
)
74+
chart_yaml.write_text(chart_content)
75+
print(f"Chart version: {current_chart_version} -> {new_chart_version}")
76+
77+
# Update web image tag in values.yaml
78+
values_content = values_yaml.read_text()
79+
values_content = re.sub(
80+
r'(^ web:\s*\n tag:\s*).*$',
81+
rf'\g<1>{args.web_version}',
82+
values_content,
83+
flags=re.MULTILINE,
84+
)
85+
values_yaml.write_text(values_content)
86+
print(f"Web image tag: {args.web_version}")
87+
88+
89+
if __name__ == "__main__":
90+
main()

0 commit comments

Comments
 (0)