FIX-#428: Add missing files in source dist on PyPI (#429) #13
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
# Workflow to build wheels for upload to PyPI. | |
# Inspired by numpy's cibuildwheel config https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml | |
name: Build and upload to PyPI | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build_sdist: | |
name: Build sdist | |
if: >- | |
github.event_name == 'workflow_dispatch' || | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout unidist | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install Cython | |
run: pip install Cython | |
- name: Build sdist | |
run: python setup.py sdist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
- name: Sanity check sdist files | |
run: ls ./dist | |
build_wheels: | |
needs: build_sdist | |
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
if: >- | |
github.event_name == 'workflow_dispatch' || | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
# Ensure that a wheel builder finishes even if another fails | |
fail-fast: false | |
matrix: | |
# GitHub Actions doesn't support pairing matrix values together, let's improvise | |
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 | |
buildplat: | |
- [ubuntu-22.04, manylinux_x86_64] | |
- [ubuntu-22.04, musllinux_x86_64] | |
- [macos-12, macosx_x86_64] | |
# Note: M1 images on Github Actions start from macOS 14 | |
- [macos-14, macosx_arm64] | |
- [windows-2022, win_amd64] | |
- [windows-2022, win32] | |
python: ["cp39", "cp310", "cp311", "cp312"] | |
steps: | |
- name: Checkout unidist | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation" | |
CIBW_BEFORE_BUILD: pip install wheel setuptools Cython | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
path: ./wheelhouse/*.whl | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
name: Upload to PyPI | |
if: >- | |
github.event_name == 'workflow_dispatch' || | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) | |
runs-on: ubuntu-latest | |
environment: pypi | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: Upload bdist and sdist | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://upload.pypi.org/legacy/ |