Skip to content

add and run dedicated wheel bulder GHA #1

add and run dedicated wheel bulder GHA

add and run dedicated wheel bulder GHA #1

name: Build and Publish Wheels
on:
release:
types: [published]
# use this for testing
push:
branches:
- main
- try_cibuildwheels
permissions:
contents: read
id-token: write # required for PyPI trusted publishing
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # macos-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
env:
# Build CPython 3.11-3.14
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
CIBW_SKIP: "*-musllinux_* pp*"
# Run tests after build (optional)
# CIBW_TEST_COMMAND: "python -c \"import ppfive; print('import ok')\""
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build backend
run: python -m pip install --upgrade build
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
publish:
name: Publish to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# publish only on version tags like v0.1.0
if: startsWith(github.ref, 'refs/tags')
environment:
name: pypi
url: https://pypi.org/project/ppfive/
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: distfiles
- name: Flatten artifacts
run: |
mkdir upload
find distfiles -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec cp {} upload/ \;
ls -la upload
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: upload