Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: 🐍 Build Python wheels

on:
push:
branches:
- "master"
tags:
- "v*"
pull_request:
branches: [ "master" ]
release:
types: [ published ]
workflow_dispatch:

concurrency:
group: wheels-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build-wheels:
name: Wheels (${{ matrix.arch }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-24.04-arm
arch: aarch64
- os: macos-14
arch: arm64
- os: macos-13
arch: x86_64
steps:
# No `lfs: true` here: wheels are built from source only, and the LFS
# fixtures are ~60 MB that no wheel job reads.
- name: Checkout repository
uses: actions/checkout@v6

- name: Build wheels
uses: pypa/cibuildwheel@v4.1.1
env:
CIBW_ARCHS: ${{ matrix.arch }}

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl

build-sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Build sdist
run: pipx run build --sdist

- name: Install NetCDF (to compile the sdist)
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
build-essential cmake libnetcdf-dev libnetcdf-c++4-dev

# Building the sdist end to end is the only check that someone on an
# unsupported platform can still `pip install forefire`.
- name: Install and smoke test the sdist
run: |
pip install dist/*.tar.gz
python tests/python/test_wheel.py
forefire -v

- name: Upload sdist
uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz

publish:
name: Publish to PyPI
needs: [ build-wheels, build-sdist ]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
environment:
name: pypi
url: https://pypi.org/p/forefire
# Trusted publishing: no API token to rotate, but the `forefire` PyPI
# project must first declare this repository and workflow as a trusted
# publisher (https://docs.pypi.org/trusted-publishers/).
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true

- name: Publish
uses: pypa/gh-action-pypi-publish@v1.14.1
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ tools/cache
tools/cmaps
bindings/python/src/pyforefire.egg-info
paper/jats
#python packaging
dist
wheelhouse
*.egg-info
#python
__pycache__
venv
Expand All @@ -32,7 +36,8 @@ docs/doxygen/xml
docs/doxygen/html

# build
CMakeLists.txt
# Do not ignore CMakeLists.txt here: it is tracked, and ignoring it makes
# packaging tools drop it from the sdist.
build.sh

#tools
Expand Down
Loading