Skip to content

Commit b9d9bae

Browse files
authored
Adding changelog update in API generator (opensearch-project#669)
* Update changelog with api generator Signed-off-by: saimedhi <saimedhi@amazon.com> * Update changelog with api generator Signed-off-by: saimedhi <saimedhi@amazon.com> --------- Signed-off-by: saimedhi <saimedhi@amazon.com>
1 parent 17a8471 commit b9d9bae

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

.github/workflows/update_api.yml

-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ jobs:
2626
python3.7 -m pip install nox
2727
- name: Generate API
2828
run: nox -s generate
29-
- name: Update CHANGELOG
30-
uses: jacobtomlinson/gha-find-replace@v3
31-
with:
32-
find: "- Your contribution here."
33-
replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec.\n- Your contribution here."
34-
include: "**CHANGELOG.md"
3529
- name: Get current date
3630
id: date
3731
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

CHANGELOG.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
2222
### Fixed
2323
- Fix KeyError when scroll return no hits ([#616](https://github.com/opensearch-project/opensearch-py/pull/616))
2424
- Fix reuse of `OpenSearch` using `Urllib3HttpConnection` and `AsyncOpenSearch` after calling `close` ([#639](https://github.com/opensearch-project/opensearch-py/pull/639))
25-
### Automated API Update
26-
- Your contribution here.
25+
### Updated APIs
2726
### Security
2827
### Dependencies
2928
- Bumps `pytest-asyncio` from <=0.21.1 to <=0.23.4

utils/generate_api.py

+27
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,33 @@ def dump_modules(modules: Any) -> None:
764764
unasync.unasync_files(filepaths, rules)
765765
blacken(CODE_ROOT / "opensearchpy")
766766

767+
# Updating the CHANGELOG.md
768+
response = requests.get(
769+
"https://api.github.com/repos/opensearch-project/opensearch-api-specification/commits"
770+
)
771+
if response.ok:
772+
commit_info = response.json()[0]
773+
commit_url = commit_info["html_url"]
774+
latest_commit_sha = commit_info.get("sha")
775+
else:
776+
raise Exception(
777+
f"Failed to fetch opensearch-api-specification commit information. Status code: {response.status_code}"
778+
)
779+
780+
with open("CHANGELOG.md", "r+", encoding="utf-8") as file:
781+
content = file.read()
782+
if "### Updated APIs" in content:
783+
file_content = content.replace(
784+
"### Updated APIs",
785+
f"### Updated APIs\n- Updated opensearch-py APIs to reflect [opensearch-api-specification@{latest_commit_sha[:7]}]({commit_url})",
786+
1,
787+
)
788+
file.seek(0)
789+
file.write(file_content)
790+
file.truncate()
791+
else:
792+
raise Exception("'Updated APIs' section is not present in CHANGELOG.md")
793+
767794

768795
if __name__ == "__main__":
769796
dump_modules(read_modules())

0 commit comments

Comments
 (0)