Fixes misconfiguration for buildwheel #3
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
# builds only on the following conditions: | |
# - pull requests into main | |
# - OR pushes of tags starting with v* | |
# - OR manual dispatch on repo | |
# publishes to test pypi if: | |
# - in auto-differentiation/xad-py repository AND | |
# - pushes of tags starting with v* | |
# - OR manual dispatch on repo | |
# publishes to real PyPI if: | |
# - publish to Test PyPI worked (with all build conditions above) | |
# - and if it's a version tag (starting with v*) | |
# | |
name: Python Wheels | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
tags: | |
- v* | |
branches: | |
- main | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
build_wheels: | |
name: Wheels | |
strategy: | |
fail-fast: false | |
matrix: | |
buildplat: ["manylinux_x86_64", "musllinux_x86_64", "macosx_x86_64", "win_amd64"] | |
python: ["cp38", "cp39", "cp310", "cp311", "cp312"] | |
include: | |
- buildplat: "manylinux_x86_64" | |
os: ubuntu-20.04 | |
python_exe: "$(which python)" | |
- buildplat: "musllinux_x86_64" | |
os: ubuntu-20.04 | |
python_exe: "$(which python)" | |
- buildplat: "macosx_x86_64" | |
os: "macos-12" | |
python_exe: "$(which python)" | |
- buildplat: "win_amd64" | |
os: windows-2022 | |
python_exe: "python" | |
exclude: | |
# gives "is not a supported wheel on this platform" for some reason | |
- buildplat: "macosx_x86_64" | |
python: "cp38" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.17.0 | |
env: | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat }} | |
CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat }} | |
path: ./wheelhouse/*.whl | |
if-no-files-found: error | |
test-publish: | |
needs: build_wheels | |
if: >- | |
github.repository == 'auto-differentiation/xad-py' && | |
(github.event_name == 'workflow_dispatch' || | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))) | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/xad | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@v1.8.12 | |
name: Publish on Test PyPI | |
with: | |
verbose: true | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true | |
publish: | |
runs-on: ubuntu-latest | |
needs: test-publish | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
environment: | |
name: pypi | |
url: https://pypi.org/p/xad | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@v1.8.12 | |
name: Publish on PyPI | |
with: | |
verbose: true | |
skip-existing: true |