Skip to content

Publish PyPI

Publish PyPI #6

Workflow file for this run

name: Publish PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish_to:
description: "Target repository"
required: true
default: "pypi"
type: choice
options:
- "pypi"
- "testpypi"
permissions:
contents: read
id-token: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13.7"
- run: python -m pip install -U pip
- run: python -m pip install build
- run: python -m build
- name: Publish to TestPyPI
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_to == 'testpypi' && startsWith(github.ref, 'refs/heads/release/test') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish_to == 'pypi') }}
uses: pypa/gh-action-pypi-publish@release/v1