From a480913eba99dd02e134e9af874d22f1cb5faf8f Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Wed, 14 Aug 2024 13:37:29 +0200 Subject: [PATCH] Pin openapi generator tag on release branches --- plugin-template | 3 +++ scripts/update_ci.sh | 1 + utils.py | 15 +++++++++++++++ 3 files changed, 19 insertions(+) mode change 100644 => 100755 utils.py diff --git a/plugin-template b/plugin-template index 119d76c2..18b77b8f 100755 --- a/plugin-template +++ b/plugin-template @@ -270,6 +270,9 @@ def main(): str(version) for version in config["supported_release_branches"] ] write_new_config = True + if config["pulp_openapi_generator_ref"] == "PIN THIS": + config["pulp_openapi_generator_ref"] = utils.fetch_latest_pog_tag() + write_new_config = True print( "\nLoaded plugin template config from " "{path}/template_config.yml.\n".format(path=plugin_root_dir) diff --git a/scripts/update_ci.sh b/scripts/update_ci.sh index d9ae7714..d465cada 100755 --- a/scripts/update_ci.sh +++ b/scripts/update_ci.sh @@ -15,6 +15,7 @@ then sed -i \ -e 's/^\(ci_update_docs: \)true$/\1false/' \ -e 's/^\(docs_test: \)true$/\1false/' \ + -e 's/^\(pulp_openapi_generator_ref: \)null/\1"PIN THIS"/' \ "template_config.yml" fi diff --git a/utils.py b/utils.py old mode 100644 new mode 100755 index fb63b4c5..4daf3e88 --- a/utils.py +++ b/utils.py @@ -58,3 +58,18 @@ def get_pulpdocs_members() -> list[str]: ) return [line.strip()[8:] for line in response.content.decode().split("\n") if "- name:" in line] + + +def fetch_latest_pog_tag(): + response = requests.get( + "https://api.github.com/repos/pulp/pulp-openapi-generator/git/refs/tags" + ) + tags = [item["ref"] for item in response.json()] + matched_tags = sorted( + [ + ((int(match.group(1)), int(match.group(2))), f"{match.group(1)}.{match.group(2)}") + for match in (re.fullmatch(r"^refs/tags/(\d{8})\.(\d+)$", tag) for tag in tags) + if match is not None + ] + ) + return matched_tags[-1][1]