This document provides step-by-step instructions for publishing AgentProbe to PyPI, based on lessons learned from actual publishing experience, including the major v0.2.0 community-first architecture release and v0.2.1 patch with --version flag.
-
Token Management: Ensure you have PyPI tokens stored securely using
pass:# Store TestPyPI token pass insert pypi/testpypi-token # Store production PyPI token pass insert pypi/production-token
-
Version Synchronization: Always keep versions synchronized across files:
pyproject.toml- Primary version sourcesrc/agentprobe/__init__.py- Used by CLI --version flag
-
Git State: Ensure all changes are committed before publishing to maintain clean release history.
-
Check Current Versions:
# Check pyproject.toml version grep "version =" pyproject.toml # Check __init__.py version grep "__version__" src/agentprobe/__init__.py
-
Update Versions Consistently:
# Update pyproject.toml # version = "0.2.x" # Increment as needed # Update __init__.py to match # __version__ = "0.2.x"
-
Test Version Display:
uv run agentprobe --version # Should output: agentprobe 0.2.x
-
Commit All Changes:
git add . git commit -m "feat: add new feature / fix: bug description 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>"
-
Tag the Release:
git tag v0.2.x git push origin main --tags
-
Clean Previous Builds (CRITICAL - prevents publishing old versions):
rm -rf dist/
-
Build the Package:
uv build
This should create:
dist/agentprobe-0.2.x.tar.gz(source distribution)dist/agentprobe-0.2.x-py3-none-any.whl(wheel)
-
Publish to TestPyPI:
uv publish --publish-url https://test.pypi.org/legacy/ --token $(pass pypi/testpypi-token) -
Test Installation and Basic Functionality:
# Test help uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentprobe --help # Test version flag uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentprobe --version # Test community features (if applicable) uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentprobe community stats
-
Verify Critical Features Work:
- CLI commands load properly
- Version displays correctly
- Community features (if using embedded API keys) connect successfully
- No import errors or missing dependencies
-
Only Proceed if TestPyPI Was Successful
⚠️ -
Publish to Production:
uv publish --token $(pass pypi/production-token)
⏰ Note: PyPI propagation can take 5-15 minutes. Be patient.
-
Test Specific Version (recommended):
# Test specific version to ensure you get the new release uvx agentprobe@0.2.x --version uvx agentprobe@0.2.x --help -
Test Latest Version:
# May take time to propagate uvx agentprobe --version uvx agentprobe --help -
Test Community Features (for versions with embedded keys):
# Clear local config for fresh test rm -f ~/.agentprobe/sharing.json # Test consent flow and community sharing echo "y" | uvx agentprobe@0.2.x test git --scenario status # Test community stats uvx agentprobe@0.2.x community stats
Problem: Trying to publish a version that already exists on PyPI.
Solution:
- Update version in BOTH
pyproject.tomlANDsrc/agentprobe/__init__.py - Clean the
dist/directory:rm -rf dist/ - Rebuild:
uv build - Retry publishing
Problem: uv publish uploads ALL files in dist/, including old versions.
Solution: Always clean the dist/ directory before building:
rm -rf dist/ && uv buildProblem: CLI shows different version than expected (e.g., agentprobe --version shows old version).
Solution: Ensure version synchronization:
# Check both files match
grep "version =" pyproject.toml
grep "__version__" src/agentprobe/__init__.py
# Update both to match, then rebuildProblem: Embedded API keys don't work or community features fail.
Solution:
- Verify embedded key is properly obfuscated in
submission.py - Test with explicit version:
uvx agentprobe@0.2.x community stats - Check API endpoint is accessible
- Clear local config:
rm -f ~/.agentprobe/sharing.json
Problem: New version not available immediately after publishing.
Solution:
- Wait 5-15 minutes for PyPI to propagate
- Use specific version syntax:
uvx agentprobe@0.2.x - Avoid
--force-reinstallwith uvx (doesn't work) - Check PyPI web interface to confirm upload
-
Always test on TestPyPI first - This catches packaging issues before they affect production users.
-
Clean builds - Always remove the
dist/directory before building to avoid publishing old versions. -
Version Synchronization - Keep
pyproject.tomland__init__.pyversions in sync for CLI --version flag. -
Git Workflow - Commit, tag, and push before publishing for clean release history.
-
Security - Use
passor another secure method to store PyPI tokens instead of environment variables. -
Verification - Always verify the published package works by installing specific version with
uvx package@version. -
Community Features - Test embedded API keys and community functionality after publishing.
-
Patience with PyPI - Allow 5-15 minutes for new releases to propagate before expecting availability.
- Patch version (0.2.x): Bug fixes, small improvements (e.g., adding --version flag)
- Minor version (0.x.0): New features, backwards compatible (e.g., community sharing system)
- Major version (x.0.0): Breaking changes, API changes
- v0.2.0: Major community-first architecture with embedded API keys, consent flow, auto-sharing
- v0.2.1: Added --version flag (patch - small improvement)
git commit -m "feat: implement community-first architecture with automatic data sharing
- Add embedded API key system with obfuscation for zero-setup experience
- Implement first-run consent dialog with clear privacy messaging
- Remove --share flag requirement - all tests now contribute automatically
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>"git commit -m "feat: add --version flag to CLI
- Add version callback function to display version info
- Support both --version and -v flags
- Update __init__.py version to match pyproject.toml
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>"- Check token storage:
pass pypi/production-tokenshould return valid token - Version conflicts: Ensure version doesn't exist on PyPI
- Clean dist:
rm -rf dist/before building - Dependencies: Verify all
pyproject.tomldependencies exist on PyPI - Network issues: Check PyPI status page
- Package not available: Wait 5-15 minutes for propagation
- Wrong version installed: Use
uvx package@specific-version - Import errors: Check dependencies and test on TestPyPI first
- Community features failing: Verify embedded API keys and network connectivity
- Regenerate tokens on PyPI/TestPyPI web interface if auth fails
- Update in
pass:pass edit pypi/production-token - Test token:
curl -H "Authorization: Bearer $(pass pypi/production-token)" https://pypi.org/simple/
# Version sync check
grep "version =" pyproject.toml && grep "__version__" src/agentprobe/__init__.py
# Clean build
rm -rf dist/ && uv build
# Test local version
uv run agentprobe --version
# Check PyPI upload
ls -la dist/ # Should only show current version files