Skip to content

Setup binder as a Python package and publish pre-built wheels to PyPI #20

Setup binder as a Python package and publish pre-built wheels to PyPI

Setup binder as a Python package and publish pre-built wheels to PyPI #20

Workflow file for this run

name: Wheels
on:
pull_request:
branches:
- master
paths:
- ".github/workflows/wheels.yml"
- "source/**"
release:
types: [published]
concurrency:
group: wheels-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-2022
- ubuntu-22.04
- macos-14
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup cibuildwheel and build wheels
run: |
pipx install cibuildwheel
pipx run cibuildwheel python
env:
CIBW_BUILD: ${{ github.event_name == 'release' && 'cp312-*' || 'cp312-macosx_universal2 cp312-win_amd64 cp312-manylinux_x86_64' }}
- name: Upload wheels to artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: cppbinder-wheels-${{ matrix.os }}-${{ github.event_name == 'release' && github.ref_name || github.sha }}
path: ./wheelhouse/*.whl
- name: Upload wheels to release
if: github.event_name == 'release'
shell: bash
run: |
gh release upload ${{ github.ref_name }} ./wheelhouse/*.whl --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-sdist:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup build and build source distribution
run: |
pipx install build
pipx run build --sdist --outdir dist
working-directory: python
- name: Upload source distribution to artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: cppbinder-sdist-${{ github.event_name == 'release' && github.ref_name || github.sha }}
path: ./python/dist/*.tar.gz
- name: Upload source distribution to release
if: github.event_name == 'release'
run: |
gh release upload ${{ github.ref_name }} ./python/dist/*.tar.gz --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: [build-wheels, build-sdist]
if: github.event_name == 'release'
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download wheels and source distribution
run: |
gh release download ${{ github.ref_name }} --pattern *.whl --pattern *.tar.gz --dir dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist