Skip to content

Upload Python Package to PyPI #37

Upload Python Package to PyPI

Upload Python Package to PyPI #37

Workflow file for this run

# 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:
publish:
description: |
Should publish to PyPA (default false for manual runs). Artifacts are
available in both cases.
default: false
type: boolean
env:
PUBLISH: ${{ inputs.publish == '' && true || inputs.publish }} # Default true for automatic runs
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@v3
with:
name: wheelhouse
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@v3
with:
name: sdist
path: ./dist/*.tar.gz
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build_source, build_wheels]
steps:
- uses: actions/checkout@v4
- name: Download sdist artifacts to dist/
uses: actions/download-artifact@v3
with:
name: sdist
path: dist/
- name: Download wheelhouse artifacts to dist/
uses: actions/download-artifact@v3
with:
name: wheelhouse
path: dist/
- name: Publish package to PyPI
if: ${{ env.PUBLISH }}
# All files in dist/ are published
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}