Skip to content

Wheels upon Wheels

Wheels upon Wheels #6

Workflow file for this run

name: Build and Publish Project on PyPI
on:
release:
workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pypi
cancel-in-progress: false
jobs:
build:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python (not macOS)
if: matrix.platform != 'macos-latest'
uses: actions/setup-python@v4
with:
python-version: 3.13
- name: Install pyenv (only macOS)
if: matrix.platform == 'macos-latest'
run: |
brew update
brew install pyenv
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc
pyenv install 3.10
pyenv install 3.11
pyenv install 3.12
pyenv global 3.10 3.11 3.12
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
pip install cibuildwheel
- name: Build wheels
run: |
cibuildwheel --output-dir dist
env:
CIBW_PLATFORM: ${{ matrix.platform == 'ubuntu-latest' && 'linux' || matrix.platform == 'macos-latest' && 'macos' }}
- name: Build source distribution (sdist)
if: matrix.platform == 'ubuntu-latest' # Only generate sdist once
run: |
python -m build --sdist --outdir dist
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: builds-${{ matrix.platform }}
path: dist-${{ matrix.platform }}
publish:
runs-on: ubuntu-latest
needs: build
# This environment is used for publishing on PyPI
environment: publish-pypi
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- name: Download Linux wheels
uses: actions/download-artifact@v3
with:
name: builds-ubuntu-latest
path: dist-ubuntu-latest
- name: Download macOS wheels
uses: actions/download-artifact@v3
with:
name: builds-macos-latest
path: dist-macos-latest
- name: Merge wheels
run: |
mkdir -p dist
mv dist-*-latest/* dist/
- name: Publish on PyPI
uses: pypa/gh-action-pypi-publish@release/v1