Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Publish Python package to PyPI

on:
push:
tags:
- 'v*'

jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build

- name: Build sdist
run: python -m build --sdist

- name: Upload sdist artifact
uses: actions/upload-artifact@v3
with:
name: sdist-artifact
path: dist/

build_wheels:
name: Build wheels on ${{ matrix.os }} for Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build

- name: Build wheels
run: python -m build --wheel

- name: Upload wheel artifact
uses: actions/upload-artifact@v3
with:
name: wheel-artifact-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/

publish:
name: Publish package to PyPI
needs: [build_sdist, build_wheels]
runs-on: ubuntu-latest
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: Combine artifacts and list
run: |
mkdir dist
shopt -s globstar
mv artifacts/**/*.whl artifacts/**/*.tar.gz dist/
ls -R dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}