Skip to content

Commit

Permalink
Pin openapi generator tag on release branches
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Aug 14, 2024
1 parent eab3a65 commit a480913
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugin-template
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions scripts/update_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions utils.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit a480913

Please sign in to comment.