This is the most secure and modern approach for 2024.
-
Set up Trusted Publishing (one-time setup):
- Follow the complete guide in
TRUSTED_PUBLISHING.md - Configure PyPI and TestPyPI trusted publishers
- Set up GitHub environments for additional security
- Follow the complete guide in
-
Install required tools:
# For local development and testing pip install pdm pip install gh # GitHub CLI for manual workflow triggers
# Run comprehensive pre-flight checks and build
python scripts/release.pyThis script will:
- ✅ Run all linting and formatting checks
- ✅ Test plugin installation and functionality
- ✅ Build packages with PDM
- ✅ Validate all required files are generated
# Trigger TestPyPI release via GitHub Actions
gh workflow run release.yml -f upload_to_pypi=false# Test installation from TestPyPI
pip install -i https://test.pypi.org/simple/ mkdocs-llmstxt-md==0.1.0
# Quick functionality test
mkdir test-install && cd test-install
echo "site_name: Test
plugins:
- llms-txt:
sections:
'Test': ['*.md']
" > mkdocs.yml
mkdir docs && echo "# Test Content" > docs/index.md
mkdocs build
# Verify outputs
ls site/ # Should contain: llms.txt, llms-full.txt, index.mdOption A: Automatic (Recommended)
# Create and push tag - triggers automatic PyPI release
git tag v0.1.0
git push origin v0.1.0Option B: Manual Trigger
# Manual workflow trigger for PyPI
gh workflow run release.yml -f upload_to_pypi=trueIf you prefer manual publishing with PDM:
# Set up PDM with PyPI credentials
pdm config pypi.username __token__
pdm config pypi.password your-pypi-api-token
pdm config repository.testpypi.username __token__
pdm config repository.testpypi.password your-testpypi-api-token# 1. Build and test locally
python scripts/release.py
# 2. Upload to TestPyPI
pdm publish --repository testpypi
# 3. Test installation
pip install -i https://test.pypi.org/simple/ mkdocs-llms-txt==0.1.0
# 4. Upload to PyPI
pdm publish
# 5. Create Git tag
git tag v0.1.0 && git push origin v0.1.0-
Pre-Release
- Update version in
pyproject.toml - Update
CHANGELOG.mdwith new features/fixes - Run
python scripts/release.py(validates everything) - Commit and push changes
- Update version in
-
Testing
- Release to TestPyPI:
gh workflow run release.yml -f upload_to_pypi=false - Test installation from TestPyPI
- Verify plugin functionality with test project
- Release to TestPyPI:
-
Production Release
- Create and push Git tag:
git tag v0.1.0 && git push origin v0.1.0 - Verify PyPI release completed successfully
- Test installation from PyPI:
pip install mkdocs-llmstxt-md - Update GitHub release notes (created automatically)
- Create and push Git tag:
-
Post-Release
- Announce release (social media, forums, etc.)
- Update documentation if needed
- Plan next version features
The GitHub Actions workflow includes:
- 🔒 Trusted Publishing: No long-lived API tokens required
- 📝 Digital Attestations: Automatic Sigstore signatures
- 🛡️ Environment Protection: Manual approval for production releases
- 🏗️ Isolated Build/Publish: Separate jobs for security
- 📦 Artifact Storage: Build artifacts stored securely between jobs
scripts/release.py- Local build and validation script.github/workflows/release.yml- Trusted publishing workflow.github/workflows/ci.yml- Continuous integrationTRUSTED_PUBLISHING.md- Detailed setup guidepyproject.toml- Package configurationCHANGELOG.md- Version history
-
Workflow fails with "OIDC token verification failed"
- Check trusted publisher configuration in PyPI matches repository details
- Verify GitHub environment names match PyPI settings
-
"Package already exists" error
- Version already published - increment version number
- For TestPyPI, this is usually safe to ignore
-
Tests fail in GitHub Actions
- Run
python scripts/release.pylocally first - Check that all dependencies are properly specified
- Run
- Check GitHub Actions logs for detailed error messages
- Review TRUSTED_PUBLISHING.md for setup issues
- Verify PyPI trusted publisher configuration
- Test locally with
python scripts/release.py
- Security: Trusted publishing is the 2024 gold standard
- Automation: Reduces human error and manual steps
- Validation: Comprehensive testing before any publication
- Flexibility: Local development with PDM, secure publishing with GitHub Actions
- Modern: Uses latest Python packaging best practices