This document explains how to release new versions of DELM to PyPI using GitHub Actions with trusted publishing.
- PyPI Account: Create an account at pypi.org
- GitHub Repository: Your code should be in a GitHub repository
- Trusted Publishing: Set up trusted publishing (required for this workflow)
-
Create PyPI Account:
- Go to pypi.org/account/register/
- Create account and verify your email
- Enable 2FA (strongly recommended)
-
Configure Trusted Publishing:
- Go to PyPI Account Settings
- Navigate to "Publishing" → "Publishing projects"
- Click "Add a new pending publisher"
- Fill in:
- PyPI project name:
delm - Owner: Your GitHub username/organization
- Repository name:
delm(or your repo name) - Workflow filename:
publish.yml - Environment name: Leave empty (uses default)
- PyPI project name:
- Click "Add"
-
Verify Setup:
- The publisher will show as "pending" until you create your first release
- Once you publish your first release, it will become "active"
-
Merge all changes to
main: All features and fixes for this release should already be merged via pull requests. -
Ensure tests pass: The CI should be green on the
mainbranch. Check GitHub Actions to verify. -
Pull latest
main:git checkout main git pull origin main
-
Review changes since last release:
git log $(git describe --tags --abbrev=0)..HEAD --oneline
# 1. Update version
python scripts/release.py 0.3.0
# 2. Commit and tag
git add .
git commit -m "Bump version to 0.3.0"
git tag v0.3.0
git push origin main --tags
# 3. Create GitHub release
# Go to GitHub → Releases → Create a new release
# Select tag v0.3.0 and publish# 1. Update version in pyproject.toml and src/delm/__init__.py
# 2. Commit changes
git add .
git commit -m "Bump version to 0.3.0"
# 3. Create and push tag
git tag v0.3.0
git push origin main --tags
# 4. Create GitHub release
# Go to GitHub → Releases → Create a new release
# Select tag v0.3.0 and publish- GitHub Actions triggers when you create a release
- Tests run
- Package builds if tests pass
- Package uploads to PyPI automatically
- Package is available at
pip install delm
.github/workflows/test.yml- Runs tests on push/PR.github/workflows/publish.yml- Publishes to PyPI on release
- Use Semantic Versioning:
MAJOR.MINOR.PATCH - Examples:
0.1.0,0.2.0,1.0.0 - Update version in both
pyproject.tomlandsrc/delm/__init__.py
The documentation is built with MkDocs and deployed to GitHub Pages.
# Install docs dependencies
pip install mkdocs mkdocs-material mkdocstrings[python]
# Serve locally with live reload
mkdocs serve
# View at http://127.0.0.1:8000# Deploy docs to gh-pages branch
mkdocs gh-deployThis command:
- Builds the documentation from
docs/andmkdocs.yml - Pushes to the
gh-pagesbranch - GitHub Pages serves from that branch automatically
- After each release: Deploy docs after publishing a new version to PyPI
- After significant doc updates: Deploy when documentation changes are merged to main
# 0. Ensure you're on main with all changes merged
git checkout main
git pull origin main
# 1. Update version
python scripts/release.py X.Y.Z
# 2. Commit and tag
git add .
git commit -m "Bump version to X.Y.Z"
git tag vX.Y.Z
# 3. Push to main with tags
git push origin main --tags
# 4. Create GitHub release (triggers PyPI publish)
# Go to GitHub → Releases → Create new release → Select tag vX.Y.Z
# 5. Deploy docs (after PyPI publish succeeds)
mkdocs gh-deploy- Trusted publishing is secure - No API tokens needed
- Enable 2FA on PyPI account
- Review GitHub Actions logs for security issues
- Keep GitHub repository private if needed during development