Publish to PyPI #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to PyPI | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
# Uses GitHub Environment for trusted publishing (OIDC) | |
# Required setup: | |
# 1. Create a GitHub environment named "release" in repo settings | |
# 2. Configure PyPI trusted publisher for this repo: | |
# - Go to PyPI project settings > Publishing | |
# - Add GitHub publisher with: | |
# - Owner: your-github-username | |
# - Repository: claude-git | |
# - Workflow: publish.yml | |
# - Environment: release (optional but recommended) | |
environment: release | |
permissions: | |
id-token: write # Required for OIDC authentication with PyPI | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python -m build | |
- name: Publish to PyPI | |
# Uses PyPA's official action with OIDC authentication | |
# No API tokens or passwords needed - uses GitHub's OIDC provider | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true |