Skip to content

Publish to PyPI

Publish to PyPI #2

Workflow file for this run

name: Publish to PyPI
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true
jobs:
publish-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Verify version
run: |
current_version=$(poetry version -s)
if [ "$current_version" != "${{ github.event.inputs.version }}" ]; then
echo "Version mismatch. pyproject.toml has $current_version, but workflow input is ${{ github.event.inputs.version }}"
exit 1
fi
- name: Build package
run: poetry build
- name: Publish to PyPI
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry publish --username __token__ --password $PYPI_API_TOKEN