From 9478884f27de7ae48d7fcab8b7ccc1aee3e3c1af Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 17 Nov 2025 15:36:20 +0100 Subject: [PATCH 1/2] Fix "draft release note found" while promoting kubectl plugin --- scripts/release/kubectl_mongodb/promote_kubectl_plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py b/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py index 47e9232ae..68e7e77ea 100644 --- a/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py +++ b/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py @@ -285,7 +285,11 @@ def upload_assets_to_github_release(asset_paths: list[str], release_version: str sys.exit(1) try: - release = repo.get_release(release_version) + gh_release = None + # list all the releases (including draft ones), and get the one corresponding to the passed release_version + for r in repo.get_releases(): + if r.tag_name == release_version: + gh_release = r except GithubException as e: logger.debug( f"ERROR: Could not find release with tag '{release_version}'. Please ensure release exists already. Error: {e}" @@ -296,7 +300,7 @@ def upload_assets_to_github_release(asset_paths: list[str], release_version: str asset_name = os.path.basename(asset_path) logger.info(f"Uploading artifact '{asset_name}' to github release as asset") try: - release.upload_asset(path=asset_path, name=asset_name, content_type="application/gzip") + gh_release.upload_asset(path=asset_path, name=asset_name, content_type="application/gzip") except GithubException as e: logger.debug(f"ERROR: Failed to upload asset {asset_name}. Error: {e}") sys.exit(2) From 318ea324aebb78dc8547a0267e93b02af8946d37 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 17 Nov 2025 18:32:11 +0100 Subject: [PATCH 2/2] Address review comment 1. Fail if gh release is not found --- .../release/kubectl_mongodb/promote_kubectl_plugin.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py b/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py index 68e7e77ea..d0aaac056 100644 --- a/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py +++ b/scripts/release/kubectl_mongodb/promote_kubectl_plugin.py @@ -290,10 +290,15 @@ def upload_assets_to_github_release(asset_paths: list[str], release_version: str for r in repo.get_releases(): if r.tag_name == release_version: gh_release = r + break + + if gh_release is None: + logger.error( + f"Could not find release (published or draft) with tag '{release_version}'. Please ensure the release exists." + ) + sys.exit(2) except GithubException as e: - logger.debug( - f"ERROR: Could not find release with tag '{release_version}'. Please ensure release exists already. Error: {e}" - ) + logger.debug(f"Failed to retrieve releases from the repository {GITHUB_REPO}. Error: {e}") sys.exit(2) for asset_path in asset_paths: