Skip to content

Add permissions for publishing to PyPI in CI workflow #30

Add permissions for publishing to PyPI in CI workflow

Add permissions for publishing to PyPI in CI workflow #30

Workflow file for this run

name: wheels
on:
push:
tags: ["v*.*.*"]
workflow_dispatch: {}
jobs:
build-linux-x86_64:
name: Linux x86_64 wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache FFTW
uses: actions/cache@v4
with:
path: .cache/fftw-*
key: fftw-${{ runner.os }}-x86_64-3.3.10
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.3
env:
CIBW_PLATFORM: linux
CIBW_ARCHS: "x86_64"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-x86_64
path: wheelhouse/*.whl
build-linux-arm64:
name: Linux aarch64 wheels
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Cache FFTW
uses: actions/cache@v4
with:
path: .cache/fftw-*
key: fftw-${{ runner.os }}-aarch64-3.3.10
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.3
env:
CIBW_PLATFORM: linux
CIBW_ARCHS: "aarch64"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux-aarch64
path: wheelhouse/*.whl
build-macos-arm:
name: macOS arm64 wheel
runs-on: macos-26
steps:
- uses: actions/checkout@v4
- name: Cache FFTW
uses: actions/cache@v4
with:
path: .cache/fftw-*
key: fftw-${{ runner.os }}-arm64-3.3.10
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build deps (brew)
run: |
brew update
brew install boost libomp pkg-config
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.3
env:
CIBW_PLATFORM: macos
MACOSX_DEPLOYMENT_TARGET: "14.0"
# Make the FFTW we compiled visible to pkg-config/CMake
PKG_CONFIG_PATH: "${{ github.workspace }}/.cache/fftw-3.3.10-macos/lib/pkgconfig"
CMAKE_PREFIX_PATH: "${{ github.workspace }}/.cache/fftw-3.3.10-macos"
LIBRARY_PATH: "${{ github.workspace }}/.cache/fftw-3.3.10-macos/lib"
CPATH: "${{ github.workspace }}/.cache/fftw-3.3.10-macos/include"
# Ensure delocate can find brew & cached libs, and enforce arch
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-wheel -L cpp_hf/.dylibs --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
- uses: actions/upload-artifact@v4
with:
name: wheels-macos-arm
path: wheelhouse/*.whl
build-macos-intel:
name: macOS x86_64 wheel
runs-on: macos-15-intel
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install FFTW and build deps via Homebrew
run: |
brew update
brew install fftw boost libomp pkg-config
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.3
env:
CIBW_PLATFORM: macos
MACOSX_DEPLOYMENT_TARGET: "14.0"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-wheel -L cpp_hf/.dylibs --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
- uses: actions/upload-artifact@v4
with:
name: wheels-macos-intel
path: wheelhouse/*.whl
publish:
name: Publish to PyPI
needs: [build-linux-x86_64, build-linux-arm64, build-macos-arm, build-macos-intel]
runs-on: ubuntu-latest
environment: wheels
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
- name: Publish to PyPI (via OIDC)
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: .