|
| 1 | +import re |
1 | 2 | from collections.abc import Generator |
2 | 3 | from functools import cache, cached_property |
3 | 4 | from typing import Any |
@@ -169,8 +170,12 @@ def _update_workflow(self, workflow_path: str) -> set[str]: |
169 | 170 | gha_utils.echo( |
170 | 171 | f'Updating "{action}" with "{updated_action}"...' |
171 | 172 | ) |
172 | | - updated_workflow_data = updated_workflow_data.replace( |
173 | | - action, updated_action |
| 173 | + updated_workflow_data = re.sub( |
| 174 | + rf"({action})(\s+|$)", |
| 175 | + rf"{updated_action}\2", |
| 176 | + updated_workflow_data, |
| 177 | + 0, |
| 178 | + re.MULTILINE, |
174 | 179 | ) |
175 | 180 | else: |
176 | 181 | gha_utils.echo(f'No updates found for "{action_repository}"') |
@@ -213,7 +218,9 @@ def _generate_updated_item_markdown( |
213 | 218 | f"branch on {version_data['commit_date']}\n" |
214 | 219 | ) |
215 | 220 |
|
216 | | - def _get_github_releases(self, action_repository: str) -> list[dict[str, Any]]: |
| 221 | + def _get_github_releases( |
| 222 | + self, action_repository: str |
| 223 | + ) -> list[dict[str, str | Version | LegacyVersion]]: |
217 | 224 | """Get the GitHub releases using GitHub API""" |
218 | 225 | url = f"{self.github_api_url}/repos/{action_repository}/releases?per_page=50" |
219 | 226 |
|
@@ -261,22 +268,23 @@ def _release_filter_function(self): |
261 | 268 | checks = [] |
262 | 269 |
|
263 | 270 | if ReleaseType.MAJOR in self.user_config.release_types: |
264 | | - checks.append(lambda r, c: r["tag_name_parsed"].major > c.major) |
| 271 | + checks.append(lambda r, c: r.major > c.major) |
265 | 272 |
|
266 | 273 | if ReleaseType.MINOR in self.user_config.release_types: |
267 | 274 | checks.append( |
268 | | - lambda r, c: r["tag_name_parsed"].major == c.major |
269 | | - and r["tag_name_parsed"].minor > c.minor, |
| 275 | + lambda r, c: r.major == c.major and r.minor > c.minor, |
270 | 276 | ) |
271 | 277 |
|
272 | 278 | if ReleaseType.PATCH in self.user_config.release_types: |
273 | 279 | checks.append( |
274 | | - lambda r, c: r["tag_name_parsed"].major == c.major |
275 | | - and r["tag_name_parsed"].minor == c.minor |
276 | | - and r["tag_name_parsed"].micro > c.micro |
| 280 | + lambda r, c: r.major == c.major |
| 281 | + and r.minor == c.minor |
| 282 | + and r.micro > c.micro |
277 | 283 | ) |
278 | 284 |
|
279 | | - def filter_func(release_tag: str, current_version: Version) -> bool: |
| 285 | + def filter_func( |
| 286 | + release_tag: LegacyVersion | Version, current_version: Version |
| 287 | + ) -> bool: |
280 | 288 | return any(check(release_tag, current_version) for check in checks) |
281 | 289 |
|
282 | 290 | return filter_func |
@@ -305,7 +313,7 @@ def _get_latest_version_release( |
305 | 313 | latest_release = next( |
306 | 314 | filter( |
307 | 315 | lambda r: self._release_filter_function( |
308 | | - r, parsed_current_version |
| 316 | + r["tag_name_parsed"], parsed_current_version |
309 | 317 | ), |
310 | 318 | github_releases, |
311 | 319 | ), |
|
0 commit comments