This guide covers how to release new versions of iriusrisk-cli to PyPI.
pip install --upgrade build twine- Create account at https://pypi.org/ (production)
- Create account at https://test.pypi.org/ (testing)
- Enable 2FA on both accounts (required for uploads)
- Create API tokens:
Create ~/.pypirc to store credentials:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
password = pypi-...your-token-here...
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-...your-testpypi-token-here...Important: Set proper permissions: chmod 600 ~/.pypirc
-
Update Version Number
Update version in both files:
setup.py(line 11)src/iriusrisk_cli/__init__.py(line 3)
-
Update CHANGELOG.md
Document changes in the new version:
## [0.2.0] - YYYY-MM-DD ### Added - New feature descriptions ### Changed - Changes to existing functionality ### Fixed - Bug fixes ### Removed - Deprecated features removed
-
Commit Version Changes
git add setup.py src/iriusrisk_cli/__init__.py CHANGELOG.md git commit -m "Bump version to 0.2.0"
-
Clean Previous Builds
rm -rf build/ dist/ src/*.egg-info -
Build Distribution Files
python -m build
This creates:
dist/iriusrisk_cli-X.Y.Z.tar.gz(source distribution)dist/iriusrisk_cli-X.Y.Z-py3-none-any.whl(wheel)
-
Verify Package Integrity
twine check dist/*Should see:
PASSEDfor all files.
-
Upload to TestPyPI
twine upload --repository testpypi dist/*Or with explicit credentials:
twine upload --repository testpypi --username __token__ --password YOUR_TESTPYPI_TOKEN dist/* -
Test Installation from TestPyPI
Create a test virtual environment:
python -m venv test-env source test-env/bin/activate # On Windows: test-env\Scripts\activate # Install from TestPyPI pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ iriusrisk-cli # Test the installation iriusrisk --version iriusrisk --help # Deactivate and remove test environment deactivate rm -rf test-env
Note:
--extra-index-urlis needed because dependencies (click, requests, etc.) are only on production PyPI.
Once TestPyPI installation is verified:
-
Upload to Production PyPI
twine upload dist/*Or with explicit credentials:
twine upload --username __token__ --password YOUR_PYPI_TOKEN dist/* -
Verify on PyPI
Check the package page: https://pypi.org/project/iriusrisk-cli/
-
Test Production Installation
python -m venv test-env source test-env/bin/activate pip install iriusrisk-cli iriusrisk --version iriusrisk test # Test connection (requires IriusRisk credentials) deactivate rm -rf test-env
-
Create Git Tag
git tag -a v0.2.0 -m "Release version 0.2.0" git push origin v0.2.0 git push origin main -
Create GitHub Release (if using GitHub)
- Go to: https://github.com/iriusrisk/iriusrisk_cli/releases/new
- Select the tag you just created
- Title:
v0.2.0 - Copy release notes from CHANGELOG.md
- Attach the distribution files from
dist/ - Click "Publish release"
-
Update README (if needed)
- Add PyPI version badge
- Update installation instructions
- Update compatibility notes
-
Announce Release
- Post on relevant channels
- Update documentation sites
- Notify users of breaking changes
Follow Semantic Versioning:
- MAJOR (X.0.0): Incompatible API changes
- MINOR (0.X.0): New features, backward compatible
- PATCH (0.0.X): Bug fixes, backward compatible
Examples:
- Bug fix:
0.1.0→0.1.1 - New feature:
0.1.1→0.2.0 - Breaking change:
0.2.0→1.0.0
- Verify API token is correct
- Ensure 2FA is enabled on your PyPI account
- Check token has upload permissions
PyPI doesn't allow re-uploading the same version. You must:
- Increment version number
- Rebuild package
- Upload new version
- Verify all dependencies are listed in
install_requiresinsetup.py - Check package structure with
python -m zipfile -l dist/*.whl - Test in clean virtual environment
- Check
MANIFEST.inincludes necessary files - Verify
package_datainsetup.pyis correct - Review build warnings for excluded files
For the first release (0.1.0):
- Package name
iriusrisk-cliis available on PyPI -
setup.pyhas complete metadata (URLs, keywords, classifiers) -
CHANGELOG.mdexists with release notes -
MANIFEST.inexplicitly includes all necessary files -
LICENSEfile exists (MIT License) -
README.mdhas installation instructions - Build and test locally successful
- Test upload to TestPyPI successful
- Test installation from TestPyPI successful
- Upload to production PyPI successful
- Test installation from production PyPI successful
- Git tag created and pushed
- GitHub release created (if applicable)
# Complete release workflow
rm -rf build/ dist/ src/*.egg-info
python -m build
twine check dist/*
twine upload --repository testpypi dist/*
# Test installation
twine upload dist/*
git tag -a v0.X.Y -m "Release version 0.X.Y"
git push origin v0.X.Y
git push origin main- PyPI Package Name:
iriusrisk-cli - Command Name:
iriusrisk - Installation:
pip install iriusrisk-cli - Usage:
iriusrisk --help - PyPI URL: https://pypi.org/project/iriusrisk-cli/
- Repository: https://github.com/iriusrisk/iriusrisk_cli
For questions or issues with the release process:
- Check PyPI documentation: https://packaging.python.org/
- Review setuptools guide: https://setuptools.pypa.io/
- Open an issue: https://github.com/iriusrisk/iriusrisk_cli/issues