Skip to content

Build and upload to PyPI #941

Build and upload to PyPI

Build and upload to PyPI #941

Workflow file for this run

name: Build and upload to PyPI
# Build on every branch push, tag push, and pull request change:
on:
push:
branches:
- main
tags:
- v*
pull_request:
schedule:
- cron: '17 3 * * 0'
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.19.2
- name: Build wheels
shell: bash
run: |
set -x
if [[ "${{ matrix.os }}" == "windows-2019" ]]; then
export CL_INC_DIR="D:/a/pyopencl/pyopencl/OpenCL-Headers/install/include"
export CL_LIB_DIR="C:/Program Files/OpenCL-ICD-Loader/lib"
fi
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1