Skip to content

generated

generated #645

# Builds on all branches & PRs
# Deploys to PyPi on "release".
name: Build and publish
on:
push: {}
repository_dispatch:
types: [ generated ]
jobs:
build:
runs-on: ubuntu-latest
name: Build the Python wheel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Python wheels
run: |
python3 -m pip install --upgrade build
python3 -m build
working-directory: src
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels
path: src/dist/*.whl
deploy:
needs: build
runs-on: ubuntu-latest
name: Deploy wheels to PyPI if tag
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if on tag
id: check
run: |
git fetch --tags
git describe --exact-match HEAD && (echo "hastag=yes" >> $GITHUB_OUTPUT) || (echo "hastag=no" >> $GITHUB_OUTPUT)
- name: Download wheels
if: steps.check.outputs.hastag == 'yes'
uses: actions/download-artifact@v4
with:
name: wheels
- name: Set up Python 3.11
if: steps.check.outputs.hastag == 'yes'
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Upgrade pip
if: steps.check.outputs.hastag == 'yes'
run: |
python -m pip install --upgrade pip
pip install twine
- name: Publish wheels to PyPI
if: steps.check.outputs.hastag == 'yes'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload *.whl