Skip to content
Open
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
44 changes: 31 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
name: Publish to PyPI

on:
release:
types: [published]
push:
tags:
- "v*"

permissions:
contents: read
id-token: write # Required for PyPI Trusted Publisher

jobs:
publish:
name: Build and publish to PyPI
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.11"

- name: Install build tools
run: pip install build twine
run: pip install build

- name: Build package
run: python -m build

- name: Check dist
run: twine check dist/*
- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # Trusted Publisher OIDC

steps:
- name: Download dist artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
Loading