Upload Python Package to PyPI #44
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
# This workflow is triggered by a new release on GitHub and then uploads | |
# MulensModel package to PyPI. | |
name: Upload Python Package to PyPI | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
disable-publish: | |
description: | | |
Disables publish to PyPA (default, true for manual runs). Artifacts are | |
available in both cases. | |
default: true | |
type: boolean | |
jobs: | |
build_wheels: | |
name: ${{ matrix.os }} ${{ matrix.cibw_archs }} ${{ matrix.cibw_build }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false # If false, continue with other matrix even if one fails | |
matrix: | |
# A matrix of OSs, Python verisons, and architectures | |
# Skips PyPy | |
os: [ubuntu-latest, macos-latest] | |
cibw_archs: [auto64, arm64] | |
cibw_build: [cp38, cp39, cp310, cp311] | |
cibw_skip: [pp*] | |
exclude: | |
- os: ubuntu-latest | |
cibw_archs: "arm64" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS: ${{ matrix.cibw_archs }} | |
CIBW_BUILD: ${{ matrix.cibw_build }} | |
CIBW_SKIP: ${{ matrix.cibw_skip }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheelhouse-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ matrix.cibw_build }} | |
path: ./wheelhouse/*.whl | |
build_source: | |
name: Build sdist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python setup.py sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: ./dist/*.tar.gz | |
publish: | |
name: Publish to PyPI | |
if: ${{ !(inputs.disable-publish || false) }} # Only skips if inputs.disable-publish is true | |
runs-on: ubuntu-latest | |
needs: [build_source, build_wheels] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download sdist artifacts to dist/ | |
uses: actions/[email protected] | |
with: | |
name: sdist | |
path: dist/ | |
- name: Download wheelhouse artifacts to dist/ | |
uses: actions/[email protected] | |
with: | |
name: wheelhouse | |
path: dist/ | |
- name: Publish package to PyPI | |
# All files in dist/ are published | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |