Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
)
Expand All @@ -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"

Expand Down
7 changes: 6 additions & 1 deletion sql_query_mcp/release_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_release_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,35 @@ 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(
should_skip_pypi_upload(
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,
)
)

Expand Down
Loading