|
| 1 | +# Releasing `kratix-sdk` |
| 2 | + |
| 3 | +This document captures the steps for cutting a new version of the SDK and publishing it to PyPI. |
| 4 | + |
| 5 | +1. **Set up Poetry credentials (one-time per machine)** |
| 6 | + ```bash |
| 7 | + poetry config repositories.testpypi https://test.pypi.org/legacy/ |
| 8 | + # Use a TestPyPI API token copied from https://test.pypi.org/manage/account/token/ |
| 9 | + poetry config pypi-token.testpypi <TESTPYPI_API_TOKEN> |
| 10 | + # For the main PyPI token (if not already configured) |
| 11 | + poetry config pypi-token.pypi <PYPI_API_TOKEN> |
| 12 | + ``` |
| 13 | + Alternatively export `POETRY_HTTP_BASIC_TESTPYPI_USERNAME="__token__"` and `POETRY_HTTP_BASIC_TESTPYPI_PASSWORD="<token>"` before publishing. |
| 14 | + |
| 15 | +2. **Prep the repo** |
| 16 | + - Update `pyproject.toml` with the new version under `[tool.poetry]`. |
| 17 | + - Add an entry to `CHANGELOG.md` summarising the release and changes. |
| 18 | + - Commit your work before building artifacts. |
| 19 | + |
| 20 | +3. **Run quality checks** |
| 21 | + ```bash |
| 22 | + make install # installs dependencies |
| 23 | + make fmt && make lint # optional but recommended |
| 24 | + make test # run pytest |
| 25 | + ``` |
| 26 | + |
| 27 | +4. **Build distributions** |
| 28 | + ```bash |
| 29 | + poetry build |
| 30 | + ls dist/ # verify the wheel and sdist exist |
| 31 | + tar tf dist/kratix-sdk-<version>.tar.gz | head |
| 32 | + ``` |
| 33 | + Inspect the contents to ensure only expected files are included. |
| 34 | + |
| 35 | +5. **Publish to TestPyPI (recommended)** |
| 36 | + ```bash |
| 37 | + poetry publish --repository testpypi --build |
| 38 | + python -m venv /tmp/kratix-sdk-test |
| 39 | + source /tmp/kratix-sdk-test/bin/activate |
| 40 | + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple kratix-sdk==<version> |
| 41 | + ``` |
| 42 | + Run a quick smoke test (`python -c "import kratix_sdk; print(kratix_sdk.__version__)"`) to ensure the build works. |
| 43 | + |
| 44 | +6. **Publish to PyPI** |
| 45 | + ```bash |
| 46 | + poetry publish --build |
| 47 | + git tag v<version> |
| 48 | + git push origin main --tags |
| 49 | + ``` |
| 50 | + PyPI credentials/API token must be configured in `~/.pypirc` beforehand. |
| 51 | + |
| 52 | +7. **Communicate the release** |
| 53 | + - Share release notes on the relevant channels. |
| 54 | + - Update downstream sample projects if they pin versions. |
0 commit comments