Publish to PyPI #2
This file contains 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: | |
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 |