This guide explains how to publish autobots-devtools-shared-lib to PyPI.
- Production PyPI: Sign up at https://pypi.org/account/register/
- TestPyPI (optional but recommended): Sign up at https://test.pypi.org/account/register/
- Enable 2FA on both accounts (required for publishing)
- Go to https://pypi.org/manage/account/token/
- Click "Add API token"
- Token name:
autobots-devtools-shared-lib-github-actions - Scope: "Entire account" (initially) or "Project: autobots-devtools-shared-lib" (after first publish)
- Copy the token immediately - it's only shown once
- Go to https://test.pypi.org/manage/account/token/
- Follow the same steps as above
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
PYPI_API_TOKEN - Value: Paste your PyPI API token (starts with
pypi-) - Click Add secret
# Configure PyPI token for local publishing
poetry config pypi-token.pypi <your-pypi-token>
# Optional: Configure TestPyPI for testing
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi <your-test-pypi-token>This method automatically publishes to PyPI when you create a GitHub release.
cd autobots-devtools-shared-lib/
# Bump version (choose one)
poetry version patch # 0.1.0 → 0.1.1 (bug fixes)
poetry version minor # 0.1.0 → 0.2.0 (new features)
poetry version major # 0.1.0 → 1.0.0 (breaking changes)git add pyproject.toml
git commit -m "Bump version to $(poetry version -s)"
git push origin main- Go to your repository's releases page
- Click Draft a new release
- Click Choose a tag → Type new tag (e.g.,
v0.1.1) → Create new tag - Release title:
v0.1.1(or your version) - Describe changes in the release notes
- Click Publish release
The GitHub Action will automatically:
- Build the package
- Publish to PyPI
- You can monitor progress in the Actions tab
Use this for testing or when you want manual control.
cd autobots-devtools-shared-lib/
# Build the package
poetry build
# Publish to TestPyPI
poetry publish -r testpypi
# Test installation from TestPyPI
pip install --index-url https://test.pypi.org/simple/ autobots-devtools-shared-libcd autobots-devtools-shared-lib/
# Build the package
poetry build
# Publish to PyPI
poetry publishAfter publishing, verify the package:
- Visit: https://pypi.org/project/autobots-devtools-shared-lib/
- Verify version, description, and metadata
# Create a test environment
python -m venv test-env
source test-env/bin/activate # On Windows: test-env\Scripts\activate
# Install from PyPI
pip install autobots-devtools-shared-lib
# Test import
python -c "import autobots_devtools_shared_lib; print(autobots_devtools_shared_lib.__version__)"
# Cleanup
deactivate
rm -rf test-envFollow SemVer:
- MAJOR (1.0.0): Breaking changes
- MINOR (0.1.0): New features, backward compatible
- PATCH (0.0.1): Bug fixes, backward compatible
# Alpha release
poetry version prerelease --prerelease=alpha # 0.1.0 → 0.1.0a1
# Beta release
poetry version prerelease --prerelease=beta # 0.1.0 → 0.1.0b1
# Release candidate
poetry version prerelease --prerelease=rc # 0.1.0 → 0.1.0rc1If autobots-devtools-shared-lib is taken on PyPI:
- Change the name in
pyproject.toml - Update all references in documentation
- Ensure the name is available: https://pypi.org/project/your-new-name/
You cannot delete or re-upload the same version. Solutions:
- Bump to a new version:
poetry version patch - Use a post-release:
poetry version 0.1.0.post1
# Verify token is configured
poetry config --list | grep pypi-token
# Re-configure token
poetry config pypi-token.pypi <your-token># Clean build artifacts
make clean
# Rebuild
poetry build
# Check for issues
poetry check- Check the Actions tab for error logs
- Verify
PYPI_API_TOKENsecret is set correctly - Ensure the token has correct permissions
- Check if package name conflicts with existing PyPI package
-
Run all checks:
make all-checks
-
Update changelog/release notes
-
Test locally:
poetry build # Test the built package -
Test on TestPyPI first (for major releases)
- Version bumped in
pyproject.toml - All tests passing
- Code formatted and linted
- Type checking passes
- Changelog updated
- README.md is current
- GitHub secret
PYPI_API_TOKENconfigured - Package name available on PyPI