Files
karaoke-gen/tests
Andrew Beveridge ☄️andClaude Opus 5.5 5005d3cb80 ci: publish to PyPI only when CLI code changed (v0.268.9) (#1145)
## Summary
PyPI publishing failed on every deploy since v0.268.4. karaoke-gen hit
PyPI's 10 GB project cap for the third time (June, Sept 29, Oct 12).
Each wheel is ~62 MiB and we published on every merge (~100/month), so
each prune only bought a couple of weeks.

PyPI is only the public `pip install` channel for the CLIs. Cloud Run
builds from source, and the encoding worker pulls the wheel from GCS. So
we now publish only when something CLI users get has changed.

## Changes
- `scripts/pypi_publish_gate.py` (stdlib): diffs
`scripts/pypi_publish_paths.txt` (`karaoke_gen/` plus the `backend/`
modules it imports) and `pyproject.toml` (ignoring the package `version
=` line only) against **the latest version on PyPI**. A skipped or
failed publish therefore never loses a CLI change. Fails open.
- `ci.yml` `package-publish`: new "Decide PyPI publish" step gates
`poetry publish` (now `--skip-existing`). **Tags and GitHub releases
still happen on every version**, because the encoding-worker gate diffs
against tags. Override with `[publish-pypi]` in the PR title/commit, or
the new workflow_dispatch input "Publish to PyPI".
- Not gated on purpose: `frontend/**` (bundled review UI) and
`backend/config.py` (cloud settings). A test keeps the backend import
list in sync, with `config.py` as the one documented exemption.
- Docs: PYPI-STORAGE-PRUNE.md, TROUBLESHOOTING.md, prune script and
reminder workflow comments.

## Impact
Replayed over v0.200 to v0.268: **24 of 136** releases would have
published (~0.7 GB/month instead of ~4 GB/month). Run against current
main, it decides "no CLI-affecting changes since v0.268.3", which is
correct for v0.268.4 to v0.268.8.

## Testing
- 15 new unit tests in `tests/unit/test_pypi_publish_gate.py`
- `make test` all green
- actionlint clean on the new step
- Local CodeRabbit review: 1 finding (doc recovery path), fixed

@coderabbitai ignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01MSW9yjwGnzz1S8MgCGm6t5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:56:24 -04:00
..