This document describes the automated workflows used for continuous integration, deployment, and publishing of the TP-Lib project.
The project uses GitHub Actions for automation with the following workflows:
- CI (Continuous Integration) - Build, test, and validate code quality
- Publish to crates.io - Release Rust crates
- Publish to PyPI - Release Python packages
- Deploy Documentation - Build and deploy API documentation
Trigger: Push or Pull Request to main or develop branches
Jobs:
- Runs all Rust tests across the workspace
- Executes with
--all-featuresto ensure all functionality is tested - Uses Python 3.12 for PyO3 bindings
- Status: ✅ Required check
- Runs performance benchmarks
- Ensures no performance regressions
- Status: ℹ️ Informational
- Sets up Python 3.12 environment
- Installs maturin for building Python bindings
- Runs pytest suite for Python package
- Status: ✅ Required check
- rustfmt: Enforces code formatting standards
- clippy: Catches common mistakes and suggests improvements
- Status: ✅ Required check
- Runs
cargo deny checkto verify:- ✅ License compatibility (Apache-2.0 compliant)
- 🔒 Security vulnerabilities (via RustSec database)
- 📦 Banned dependencies
- 🌐 Allowed sources (crates.io only)
- See SECURITY.md for details on known issues
- Status: ✅ Required check
Caching: All jobs cache Cargo registry, git index, and build artifacts to speed up builds.
File: .github/workflows/publish-crates.yml
Trigger: GitHub Release creation with tag matching v*.*.* (e.g., v1.0.0)
Process:
-
Version Verification
- Extracts version from git tag (e.g.,
v1.2.3→1.2.3) - Compares with version in
Cargo.toml - Fails if versions don't match
- Extracts version from git tag (e.g.,
-
Test Execution
- Runs full test suite before publishing
- Ensures release quality
-
Sequential Publishing
- Publishes
tp-corefirst (core library) - Waits 30 seconds for crates.io indexing
- Publishes
tp-cli(depends on tp-core) - Publishes
tp-py(Python bindings, depends on tp-core)
- Publishes
Authentication: OIDC Trusted Publishing (no secrets needed)
- The workflow uses OpenID Connect to authenticate with crates.io
- No API tokens need to be stored in GitHub secrets
- Configure trusted publisher at: https://crates.io/settings/tokens
Usage:
# 1. Update version in Cargo.toml files
# 2. Commit changes
git commit -am "chore: bump version to 1.2.3"
# 3. Create and push tag
git tag v1.2.3
git push origin v1.2.3
# 4. Create GitHub Release
# Go to: https://github.com/matdata-eu/tp-lib/releases/new
# - Tag: v1.2.3
# - Title: "Release 1.2.3"
# - Description: Changelog
# - Click "Publish release"File: .github/workflows/publish-pypi.yml
Trigger: GitHub Release creation with tag matching v*.*.*
Process:
-
Build Wheels (Multi-platform)
- Builds Python wheels for:
- Linux (ubuntu-latest)
- Windows (windows-latest)
- macOS (macos-latest)
- Python versions: 3.9, 3.10, 3.11, 3.12
- Uses
maturinto compile Rust extension module
- Builds Python wheels for:
-
Build Source Distribution
- Creates source tarball (
.tar.gz) - Built on Linux with Python 3.12
- Creates source tarball (
-
Publish to PyPI
- Collects all wheels and sdist
- Uploads to PyPI using OIDC trusted publishing
Authentication: OIDC Trusted Publishing (no secrets needed)
- The workflow uses OpenID Connect to authenticate with PyPI
- No API tokens need to be stored in GitHub secrets
- Configure trusted publisher at: https://pypi.org/manage/account/publishing/
Installation after publishing:
pip install tp-libFile: .github/workflows/docs.yml
Trigger:
- Push to
mainbranch - Manual workflow dispatch
Process:
-
Build Documentation
- Runs
cargo doc --workspace --no-deps --all-features - Generates rustdoc for all crates
- Includes private items with
--document-private-items
- Runs
-
Create Index Page
- Generates
index.htmlat root - Auto-redirects to
tp_lib_core/index.html - Provides navigation links to all crates
- Generates
-
Deploy to GitHub Pages
- Uploads to
gh-pagesbranch - Available at:
https://matdata-eu.github.io/tp-lib/
- Uploads to
Setup Requirements:
- Enable GitHub Pages in repository settings
- Source: GitHub Actions
- Configure trusted publishers on crates.io and PyPI (see below)
Access: https://matdata-eu.github.io/tp-lib/
Both crates.io and PyPI support OIDC (OpenID Connect) trusted publishing with GitHub Actions, eliminating the need to store API tokens as secrets.
- Go to https://crates.io/settings/tokens
- Under "Trusted Publishing", click "Add trusted publisher"
- Fill in:
- Repository Owner:
matdata-eu - Repository Name:
tp-lib - Workflow:
.github/workflows/publish-crates.yml
- Repository Owner:
- Click "Add publisher"
The workflow will automatically authenticate using GitHub's OIDC token when publishing.
- Go to https://pypi.org/manage/account/publishing/
- Under "Add a new publisher", fill in:
- PyPI Project Name:
tp-lib - Owner:
matdata-eu - Repository name:
tp-lib - Workflow name:
publish-pypi.yml - Environment name:
pypi
- PyPI Project Name:
- Click "Add"
For the initial publication to PyPI (before the project exists), you'll need to:
- Either use a temporary API token for the first release
- Or pre-register the project name on PyPI
After the first release, all subsequent releases will use trusted publishing automatically.
graph LR
A[Push to main/develop] --> B[CI Workflow]
C[Create Release v1.2.3] --> D[Publish to crates.io]
C --> E[Publish to PyPI]
A --> F[Deploy Docs]
B --> |Must Pass| C
D --> |Sequential| D1[tp-core]
D1 --> D2[tp-cli]
D1 --> D3[tp-py]
E --> |Parallel| E1[Build Wheels]
E --> |Parallel| E2[Build sdist]
E1 --> E3[Publish]
E2 --> E3
The workflows use OpenID Connect (OIDC) for secure, token-less authentication:
- No secrets to manage: GitHub automatically provides OIDC tokens
- Better security: Tokens are short-lived and scoped to specific workflows
- Automatic rotation: No need to worry about token expiration
Both crates.io and PyPI must be configured to trust this GitHub repository:
| Platform | Configuration URL |
|---|---|
| crates.io | https://crates.io/settings/tokens |
| PyPI | https://pypi.org/manage/account/publishing/ |
See the "OIDC Trusted Publishing Setup" section above for detailed steps.
Recommended branch protection rules for main:
- ✅ Require status checks to pass before merging
- CI / Test Suite
- CI / Python Tests
- CI / Linting
- CI / License & Security Check
- ✅ Require branches to be up to date before merging
- ✅ Require linear history
- ✅ Include administrators
Before creating a release:
- All CI checks passing on
main - Version updated in all
Cargo.tomlfiles -
CHANGELOG.mdupdated with release notes -
cargo deny checkpasses (no security issues) - All tests passing locally:
cargo test --all-features - Python tests passing:
cd tp-py && pytest - Documentation builds:
cargo doc --no-deps - Docker builds successfully
Creating a release:
-
Update versions:
# Update Cargo.toml files with new version # Update tp-py/Cargo.toml # Update tp-py/pyproject.toml
-
Commit and tag:
git commit -am "chore: release v1.2.3" git tag v1.2.3 git push origin main git push origin v1.2.3 -
Create GitHub Release:
- Go to https://github.com/matdata-eu/tp-lib/releases/new
- Select tag:
v1.2.3 - Add release title:
Release 1.2.3 - Add changelog from
CHANGELOG.md - Click "Publish release"
-
Monitor workflows:
- Watch Actions tab for workflow execution
- Verify crates.io publication
- Verify PyPI publication
- Verify documentation deployment
Problem: Security vulnerabilities detected
Solution:
- Check SECURITY.md for known issues
- Update dependencies:
cargo update - If transitive, add to
deny.tomlignore list with justification
Problem: Package already exists
Solution:
- Ensure version was incremented
- PyPI doesn't allow re-uploading same version
Problem: GitHub Pages shows old docs
Solution:
- Check workflow logs for errors
- Verify GitHub Pages is enabled
- Try manual trigger: Actions → Deploy Documentation → Run workflow
Problem: Tag version doesn't match Cargo.toml
Solution:
# Update all Cargo.toml files
vim Cargo.toml tp-core/Cargo.toml tp-cli/Cargo.toml tp-py/Cargo.toml
# Commit
git commit -am "chore: fix version to 1.2.3"
# Delete and recreate tag
git tag -d v1.2.3
git push origin :refs/tags/v1.2.3
git tag v1.2.3
git push origin v1.2.3When contributing, ensure:
- All CI checks pass on your branch
- Code is formatted:
cargo fmt --all - No clippy warnings:
cargo clippy --all-targets --all-features - Tests pass:
cargo test --all-features - License check passes:
cargo deny check
Monitor workflow status:
- Actions Tab: https://github.com/matdata-eu/tp-lib/actions
- crates.io: https://crates.io/crates/tp-core
- PyPI: https://pypi.org/project/tp-lib/
- Documentation: https://matdata-eu.github.io/tp-lib/
For questions or issues with CI/CD, please open an issue on GitHub.