Skip to content

Commit 8a39c54

Browse files
committed
fix(ci): use new helm repo for version update workflow
Signed-off-by: Fatih Acar <[email protected]>
1 parent 333b5c6 commit 8a39c54

File tree

2 files changed

+67
-51
lines changed

2 files changed

+67
-51
lines changed

.github/workflows/update-compose-file-and-chart.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,36 @@ jobs:
5555
- name: "Update Infrahub Image Version in docker-compose.yml file"
5656
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
5757
run: "poetry run invoke release.update-docker-compose"
58-
- name: "Update AppVersion in helm/chart.yaml file"
59-
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
60-
run: "poetry run invoke release.update-helm-chart"
6158
- name: "Update Versions in python_testcontainers/pyproject.toml"
6259
run: "poetry run invoke release.update-test-containers"
63-
- name: Commit docker-compose.yml and helm
60+
- name: Commit docker-compose.yml
6461
uses: github-actions-x/[email protected]
6562
with:
6663
github-token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
6764
push-branch: 'stable'
68-
commit-message: 'chore: update docker-compose and helm chart'
65+
commit-message: 'chore: update docker-compose'
6966
files: |
7067
docker-compose.yml
71-
helm/Chart.yaml
7268
python_testcontainers/pyproject.toml
7369
name: opsmill-bot
7470
7571
rebase: true
72+
73+
- name: Checkout infrahub-helm
74+
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
75+
uses: actions/checkout@v4
76+
with:
77+
repository: opsmill/infrahub-helm
78+
path: helm
79+
token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
80+
81+
- name: "Update AppVersion in helm/chart.yaml file"
82+
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
83+
run: "poetry run invoke release.update-helm-chart"
84+
85+
- name: Commit helm
86+
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
87+
working-directory: helm
88+
run: |
89+
git commit -a -m 'chore: bump appVersion'
90+
git push

tasks/release.py

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -96,57 +96,58 @@ def ship(context: Context) -> None:
9696

9797

9898
@task
99-
def update_helm_chart(context: Context, chart_file: str | None = "helm/Chart.yaml") -> None:
99+
def update_helm_chart(context: Context, chart_repo: str | None = "helm/") -> None:
100100
"""Update helm/Chart.yaml with the current version from pyproject.toml."""
101101
print(" - [release] Update Helm chart")
102102

103103
# Get the app version directly from pyproject.toml
104104
app_version = get_version_from_pyproject() # Returns a string like '1.1.0a1'
105105

106-
# Initialize YAML and load the Chart.yaml file
107-
yaml: YAML = init_yaml_obj()
108-
chart_path = Path(chart_file)
109-
chart_yaml = yaml.load(chart_path)
110-
111-
if "appVersion" not in chart_yaml:
112-
raise ValueError(f"appVersion not found in {chart_file}; no updates made.")
113-
114-
old_app_version = chart_yaml.get("appVersion", "")
115-
if old_app_version == app_version:
116-
print(
117-
f"{chart_file} updates not required, `appVersion` of {old_app_version} matches current from `pyproject.toml`"
118-
)
119-
return
120-
121-
# Handle Helm chart version increment
122-
old_helm_version = chart_yaml.get("version", "")
123-
if not old_helm_version:
124-
raise ValueError(f"Helm chart `version` not found in {chart_file}; no updates made.")
125-
126-
# Split the Helm chart version into components for increment logic
127-
major, minor, patch = map(int, old_helm_version.split("."))
128-
new_helm_version = f"{major}.{minor}.{patch}"
129-
130-
# Determine the appropriate increment
131-
try:
132-
if app_version > old_app_version:
133-
if int(app_version.split(".")[0]) > major:
134-
new_helm_version = f"{major + 1}.0.0"
135-
elif int(app_version.split(".")[1]) > minor:
136-
new_helm_version = f"{major}.{minor + 1}.0"
137-
elif int(app_version.split(".")[2].split("a")[0]) > patch: # For alpha, beta handling
138-
new_helm_version = f"{major}.{minor}.{patch + 1}"
139-
except Exception:
140-
# Fallback in case app_version has non-standard format for Helm comparison
141-
print(f"Warning: Unable to strictly compare versions, using default Helm chart version: {new_helm_version}")
142-
143-
# Update the YAML
144-
chart_yaml["appVersion"] = app_version
145-
chart_yaml["version"] = new_helm_version
146-
147-
yaml.dump(chart_yaml, chart_path)
148-
149-
print(f"{chart_file} updated with Helm `version`: {new_helm_version} and `appVersion`: {app_version}")
106+
for chart in ["infrahub", "infrahub-enterprise"]:
107+
# Initialize YAML and load the Chart.yaml file
108+
yaml: YAML = init_yaml_obj()
109+
chart_path = Path(chart_repo) / "charts" / Path(chart) / "Chart.yaml"
110+
chart_yaml = yaml.load(chart_path)
111+
112+
if "appVersion" not in chart_yaml:
113+
raise ValueError(f"appVersion not found in {str(chart_path)}; no updates made.")
114+
115+
old_app_version = chart_yaml.get("appVersion", "")
116+
if old_app_version == app_version:
117+
print(
118+
f"{str(chart_path)} updates not required, `appVersion` of {old_app_version} matches current from `pyproject.toml`"
119+
)
120+
return
121+
122+
# Handle Helm chart version increment
123+
old_helm_version = chart_yaml.get("version", "")
124+
if not old_helm_version:
125+
raise ValueError(f"Helm chart `version` not found in {str(chart_path)}; no updates made.")
126+
127+
# Split the Helm chart version into components for increment logic
128+
major, minor, patch = map(int, old_helm_version.split("."))
129+
new_helm_version = f"{major}.{minor}.{patch}"
130+
131+
# Determine the appropriate increment
132+
try:
133+
if app_version > old_app_version:
134+
if int(app_version.split(".")[0]) > major:
135+
new_helm_version = f"{major + 1}.0.0"
136+
elif int(app_version.split(".")[1]) > minor:
137+
new_helm_version = f"{major}.{minor + 1}.0"
138+
elif int(app_version.split(".")[2].split("a")[0]) > patch: # For alpha, beta handling
139+
new_helm_version = f"{major}.{minor}.{patch + 1}"
140+
except Exception:
141+
# Fallback in case app_version has non-standard format for Helm comparison
142+
print(f"Warning: Unable to strictly compare versions, using default Helm chart version: {new_helm_version}")
143+
144+
# Update the YAML
145+
chart_yaml["appVersion"] = app_version
146+
chart_yaml["version"] = new_helm_version
147+
148+
yaml.dump(chart_yaml, chart_path)
149+
150+
print(f"{str(chart_path)} updated with Helm `version`: {new_helm_version} and `appVersion`: {app_version}")
150151

151152

152153
@task

0 commit comments

Comments
 (0)