# This is a reusable GitHub Actions workflow for building Python wheels.
# Usage:
# Call this workflow from another workflow using the 'uses:' syntax and provide the 'python-version' input.
# This workflow checks out the code, sets up Python, installs build tools, builds the wheel, and uploads it as an artifact named 'wheel'.
# Example call:
# jobs:
# build:
# uses: ./.github/workflows/reusable-build-wheel.yml
# with:
# python-version: "3.10"
#
# This workflow does NOT publish to PyPI. Use a separate publish workflow for that purpose.
name: Reusable Build Wheel
on:
workflow_call:
inputs:
python-version:
required: true
type: string
jobs:
build-wheel:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Upgrade pip and install build tools
run: |
python -m pip install --upgrade pip
pip install build wheel
- name: Build wheel
run: python -m build --wheel
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl