Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CD

on:
# Deploy to TestPyPI after CI passes on main branch
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [main]

# Deploy to PyPI on version tags
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest
# Only run if CI workflow succeeded (for main branch) or on tags
if: |
(github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') ||
startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for hatch-vcs to work properly

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Set up Python
run: uv python install 3.9

- name: Install dependencies
run: uv sync --group dev

- name: Build package
run: uv build

- name: Publish to TestPyPI (on main branch)
if: github.ref == 'refs/heads/main'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: uv run twine upload --repository testpypi dist/*

- name: Publish to PyPI (on tags)
if: startsWith(github.ref, 'refs/tags/v')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: uv run twine upload dist/*