This document describes how to publish new releases of python-kanka to PyPI.
- PyPI Account: You need an account on PyPI and optionally Test PyPI
- PyPI API Token: Generate an API token from your PyPI account settings
- GitHub Repository Access: Push access to the repository for creating tags and releases
Add your PyPI API token as a GitHub secret:
- Go to Settings → Secrets and variables → Actions
- Add a new repository secret named
PYPI_API_TOKENwith your PyPI token - (Optional) Add
TEST_PYPI_API_TOKENfor Test PyPI
Note: The GitHub Actions workflow uses trusted publishing, so you may not need tokens if you configure it on PyPI.
Edit setup.py and update the version number:
version="2.0.1", # Update thisDocument all changes since the last release in CHANGELOG.md.
git add setup.py CHANGELOG.md
git commit -m "Bump version to 2.0.1"
git push origin maingit tag -a v2.0.1 -m "Release version 2.0.1"
git push origin v2.0.1- Go to the repository's Releases page
- Click "Create a new release"
- Choose the tag you just created
- Set the release title (e.g., "v2.0.1")
- Add release notes (can copy from CHANGELOG.md)
- Click "Publish release"
The GitHub Actions workflow will automatically:
- Build the package
- Run tests
- Upload to PyPI
Check that the package is available:
pip install --upgrade python-kankaIf you need to publish manually:
pip install --upgrade build twinepython -m buildThis creates files in the dist/ directory:
python_kanka-2.0.1-py3-none-any.whlpython_kanka-2.0.1.tar.gz
twine check dist/*twine upload --repository testpypi dist/*Test installation:
pip install --index-url https://test.pypi.org/simple/ python-kankatwine upload dist/*You can manually trigger the publish workflow to test on Test PyPI:
- Go to Actions → Publish to PyPI
- Click "Run workflow"
- Leave "Publish to Test PyPI" checked
- Click "Run workflow"
Consider using a tool like bump2version for consistent version updates:
pip install bump2version
# For patch release (2.0.0 → 2.0.1)
bump2version patch
# For minor release (2.0.1 → 2.1.0)
bump2version minor
# For major release (2.1.0 → 3.0.0)
bump2version majorPyPI can take a few minutes to update. Wait and try again.
Ensure all dependencies are installed:
pip install -r requirements.txt
pip install -r dev-requirements.txt- Verify your API token is correct
- Ensure the token has upload permissions
- Check if you're using the correct repository URL
After a successful release:
- Update the version in
setup.pyto the next development version (e.g., "2.0.2.dev0") - Commit with message "Start development on 2.0.2"
- Announce the release (optional)