Adding changelog update in API generator (#669)
* Update changelog with api generator Signed-off-by: saimedhi <[email protected]> * Update changelog with api generator Signed-off-by: saimedhi <[email protected]> --------- Signed-off-by: saimedhi <[email protected]>
This commit is contained in:
@@ -764,6 +764,33 @@ def dump_modules(modules: Any) -> None:
|
||||
unasync.unasync_files(filepaths, rules)
|
||||
blacken(CODE_ROOT / "opensearchpy")
|
||||
|
||||
# Updating the CHANGELOG.md
|
||||
response = requests.get(
|
||||
"https://api.github.com/repos/opensearch-project/opensearch-api-specification/commits"
|
||||
)
|
||||
if response.ok:
|
||||
commit_info = response.json()[0]
|
||||
commit_url = commit_info["html_url"]
|
||||
latest_commit_sha = commit_info.get("sha")
|
||||
else:
|
||||
raise Exception(
|
||||
f"Failed to fetch opensearch-api-specification commit information. Status code: {response.status_code}"
|
||||
)
|
||||
|
||||
with open("CHANGELOG.md", "r+", encoding="utf-8") as file:
|
||||
content = file.read()
|
||||
if "### Updated APIs" in content:
|
||||
file_content = content.replace(
|
||||
"### Updated APIs",
|
||||
f"### Updated APIs\n- Updated opensearch-py APIs to reflect [opensearch-api-specification@{latest_commit_sha[:7]}]({commit_url})",
|
||||
1,
|
||||
)
|
||||
file.seek(0)
|
||||
file.write(file_content)
|
||||
file.truncate()
|
||||
else:
|
||||
raise Exception("'Updated APIs' section is not present in CHANGELOG.md")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dump_modules(read_modules())
|
||||
|
||||
Reference in New Issue
Block a user