Skip to content

Publish to PyPI

Publish to PyPI #9

Workflow file for this run

name: Publish to PyPI
on:
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m twine upload dist/*
- name: Get version from setup.py
id: package-version
run: |
VERSION=$(grep "VERSION = " setup.py | cut -d'"' -f2)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from setup.py"
exit 1
fi
echo "current-version=$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
name: v${{ steps.package-version.outputs.current-version }}
draft: false
prerelease: false
generate_release_notes: true