@@ -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