Skip to content

Publish

Publish #5

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
target:
description: "Publish target"
required: true
type: choice
options:
- testpypi
- pypi
default: "testpypi"
dry_run:
description: "Build only, skip upload"
required: false
type: choice
options:
- "false"
- "true"
default: "false"
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tooling
run: python -m pip install --upgrade pip build twine
- name: Build package
run: python -m build
- name: Check package metadata
run: python -m twine check dist/*
- name: Publish to TestPyPI
if: ${{ inputs.target == 'testpypi' && inputs.dry_run != 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: ${{ inputs.target == 'pypi' && inputs.dry_run != 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}