Skip to content

Build and Publish

Build and Publish #125

name: "Build and Publish"
on:
push:
branches: [ develop ]
tags: [ '*' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
schedule:
- cron: '30 22 15 * *'
jobs:
build:
name: Build Python distributions
runs-on: ubuntu-latest
strategy:
# Matrix to exercise the build backend on all versions of python supported
matrix:
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install pypa/build
run: |
pip install build
python --version
pip list
- name: Build a binary wheel and a source tarball
run: python -m build
- uses: actions/upload-artifact@v4
with:
name: distributions-built-with-py${{ matrix.python }}
path: dist/
publish:
name: "Publish to PyPI"
# Only upload for an actual tag
if: ${{ startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/download-artifact@v4
with:
# Download distributions from one job of the matrix
name: "distributions-built-with-py-3.12"
path: "dist"
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}