diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fa9d27..631d80a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -136,7 +136,12 @@ jobs: RECOVERY_RUN=true fi - skip_upload=$(PYTHONPATH=. RECOVERY_RUN="$RECOVERY_RUN" PYPI_VERSION_EXISTS="$PYPI_VERSION_EXISTS" RECOVERY_CONFIRMED="$RECOVERY_CONFIRMED" python - <<'PY' + GITHUB_RELEASE_EXISTS=false + if gh release view "$EFFECTIVE_TAG" >/dev/null 2>&1; then + GITHUB_RELEASE_EXISTS=true + fi + + skip_upload=$(PYTHONPATH=. RECOVERY_RUN="$RECOVERY_RUN" PYPI_VERSION_EXISTS="$PYPI_VERSION_EXISTS" RECOVERY_CONFIRMED="$RECOVERY_CONFIRMED" GITHUB_RELEASE_EXISTS="$GITHUB_RELEASE_EXISTS" python - <<'PY' from sql_query_mcp.release_metadata import should_skip_pypi_upload import os @@ -146,6 +151,7 @@ jobs: is_recovery_run=os.environ["RECOVERY_RUN"] == "true", pypi_version_exists=os.environ["PYPI_VERSION_EXISTS"] == "true", recovery_confirmed=os.environ["RECOVERY_CONFIRMED"] == "true", + github_release_exists=os.environ["GITHUB_RELEASE_EXISTS"] == "true", ) else "false" ) @@ -155,9 +161,11 @@ jobs: echo "skip_upload=$skip_upload" echo "pypi_version_exists=$PYPI_VERSION_EXISTS" echo "recovery_run=$RECOVERY_RUN" + echo "github_release_exists=$GITHUB_RELEASE_EXISTS" } >> "$GITHUB_OUTPUT" { echo "PyPI exists: $PYPI_VERSION_EXISTS" + echo "GitHub Release exists: $GITHUB_RELEASE_EXISTS" echo "Skip upload: $skip_upload" } >> "$GITHUB_STEP_SUMMARY" diff --git a/sql_query_mcp/release_metadata.py b/sql_query_mcp/release_metadata.py index 395f48b..4a7095f 100644 --- a/sql_query_mcp/release_metadata.py +++ b/sql_query_mcp/release_metadata.py @@ -60,8 +60,13 @@ def should_skip_pypi_upload( is_recovery_run: bool, pypi_version_exists: bool, recovery_confirmed: bool, + github_release_exists: bool, ) -> bool: - return is_recovery_run and pypi_version_exists and recovery_confirmed + if not pypi_version_exists: + return False + if is_recovery_run and recovery_confirmed: + return True + return github_release_exists def decide_backmerge_action(target: str, has_open_pr: bool, has_diff: bool) -> str: diff --git a/tests/test_release_metadata.py b/tests/test_release_metadata.py index 1c435cf..4ec78fd 100644 --- a/tests/test_release_metadata.py +++ b/tests/test_release_metadata.py @@ -87,6 +87,7 @@ def test_should_skip_pypi_upload_requires_all_conditions(self) -> None: is_recovery_run=True, pypi_version_exists=True, recovery_confirmed=True, + github_release_exists=False, ) ) self.assertFalse( @@ -94,6 +95,27 @@ def test_should_skip_pypi_upload_requires_all_conditions(self) -> None: is_recovery_run=True, pypi_version_exists=False, recovery_confirmed=True, + github_release_exists=False, + ) + ) + + def test_should_skip_pypi_upload_for_rerun_after_release_exists(self) -> None: + self.assertTrue( + should_skip_pypi_upload( + is_recovery_run=False, + pypi_version_exists=True, + recovery_confirmed=False, + github_release_exists=True, + ) + ) + + def test_should_skip_pypi_upload_requires_signal_when_release_missing(self) -> None: + self.assertFalse( + should_skip_pypi_upload( + is_recovery_run=False, + pypi_version_exists=True, + recovery_confirmed=False, + github_release_exists=False, ) )