🚀 PyPI Deployment Setup Guide for UnicoLab
This guide will help you set up automated PyPI deployment for the KMR package under the UnicoLab organization.
📋 Prerequisites
- UnicoLab PyPI Account: Create a PyPI account for UnicoLab organization
- GitHub Repository: Ensure the repository is under
UnicoLab/keras-model-registry
- GitHub Actions: Enable GitHub Actions in repository settings
🔧 Step 1: Create UnicoLab PyPI Account
1.1 Register PyPI Account
- Go to PyPI Registration
- Use an official UnicoLab email address (e.g.,
contact@unicolab.ai
) - Choose a username like
unicolab
orunicolab-org
- Complete the registration process
1.2 Generate API Token
- Log into your PyPI account
- Go to Account Settings → API tokens
- Click Add API token
- Choose Scope:
Entire account (all projects)
- Token name:
KMR Package Deployment
- Copy the generated token (starts with
pypi-
)
🔐 Step 2: Configure GitHub Secrets
2.1 Add PyPI Token to GitHub
- Go to your GitHub repository:
https://github.com/UnicoLab/keras-model-registry
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
PYPI_API_TOKEN
- Value: Paste your PyPI API token
- Click Add secret
2.2 Verify Secrets
Your repository should now have:
- PYPI_API_TOKEN
: Your PyPI API token
- GITHUB_TOKEN
: Automatically provided by GitHub
🚀 Step 3: Test Deployment
3.1 Manual Deployment (Recommended First)
- Go to Actions tab in your GitHub repository
- Select Publish to PyPI - UnicoLab workflow
- Click Run workflow
- Enter version:
0.1.0
- Click Run workflow
3.2 Automatic Deployment via Tags
# Create and push a tag to trigger automatic deployment
git tag v0.1.0
git push origin v0.1.0
📦 Step 4: Verify Package on PyPI
- Go to PyPI
- Verify the package appears with UnicoLab branding
- Test installation:
pip install kmr
🔄 Step 5: Update Package Information
5.1 Package Metadata
The pyproject.toml
is already configured with:
- Name: kmr
- Author: UnicoLab <contact@unicolab.ai>
- Homepage: https://unicolab.ai
- Repository: https://github.com/UnicoLab/keras-model-registry
- Documentation: https://unicolab.github.io/keras-model-registry/
5.2 Package Description
The package description includes UnicoLab branding:
"Reusable Model Architecture Bricks in Keras - Enterprise AI by UnicoLab"
🎯 Step 6: Release Process
6.1 Version Bumping
Update version in pyproject.toml
:
[tool.poetry]
version = "0.1.1" # Increment as needed
6.2 Create Release
# Update version
poetry version patch # or minor, major
# Create tag
git add pyproject.toml
git commit -m "Bump version to $(poetry version -s)"
git tag v$(poetry version -s)
git push origin main --tags
6.3 GitHub Release
The workflow automatically creates a GitHub release with: - Release notes - Documentation deployment - PyPI package upload
🛠️ Workflow Features
The PUBLISH_PYPI.yml
workflow includes:
✅ Automated Testing
- Runs full test suite before deployment
- Ensures code quality with linting
- Validates package structure
✅ Build Process
- Uses Poetry for dependency management
- Builds wheel and source distributions
- Validates package metadata
✅ Deployment
- Uploads to PyPI with proper authentication
- Creates GitHub release automatically
- Deploys documentation to GitHub Pages
✅ Security
- Uses GitHub secrets for API tokens
- No hardcoded credentials
- Secure token handling
🔍 Troubleshooting
Common Issues
1. Authentication Failed
Error: HTTP 403: The user 'unicolab' isn't allowed to upload to project 'kmr'
2. Package Already Exists
Error: File already exists
pyproject.toml
.
3. Build Failed
Error: Poetry build failed
pyproject.toml
syntax and dependencies.
Debug Steps
- Check GitHub Actions logs
- Verify PyPI token permissions
- Test local build:
poetry build
- Validate package:
poetry check
📚 Additional Resources
🎉 Success Checklist
- UnicoLab PyPI account created
- API token generated and added to GitHub secrets
- Package builds successfully locally
- First deployment to PyPI successful
- Package appears on PyPI with correct metadata
- Documentation deployed to GitHub Pages
- Installation test:
pip install kmr
🚀 Next Steps
After successful deployment:
- Announce Release: Share on UnicoLab social media and blog
- Monitor Usage: Track PyPI download statistics
- Gather Feedback: Collect user feedback for improvements
- Plan Next Release: Prepare roadmap for future versions
Need Help? Contact the UnicoLab team at contact@unicolab.ai