Build wheel and publish #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build wheel and publish | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
env: | |
CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-*" | |
CIBW_SKIP: "*-win32 *musllinux*" | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_BEFORE_BUILD: pip install numpy --config-settings=setup-args="-Dallow-noblas=true" | |
jobs: | |
build-wheels: | |
name: Build ${{ matrix.python-version }} wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: "3.10" | |
- name: Install Fortran compiler (Linux) | |
if: runner.os == 'Linux' | |
run: sudo apt-get install -y gfortran | |
- name: Install Fortran compiler (Mac) | |
if: runner.os == 'macOS' | |
run: | | |
brew install gcc | |
sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran || true | |
- name: Setup Mac | |
if: runner.os == 'macOS' | |
run: | | |
python -m pip install numpy h5py versioneer | |
- name: Setup Linux | |
if: runner.os == 'Linux' | |
run: | | |
python -m pip install numpy h5py versioneer | |
- name: Build wheels | |
run: | | |
sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran || true | |
sudo mkdir /usr/local/gfortran || true | |
sudo ln -s /usr/local/Cellar/gcc/$(brew list --versions gcc | cut -d ' ' -f 2)/lib/gcc/$(brew list --versions gcc | cut -d ' ' -f 2 | cut -d. -f1-2) /usr/local/gfortran/lib || true | |
gfortran --version | |
python -m pip install cibuildwheel meson ninja | |
meson setup build | |
meson compile -C build | |
python -m cibuildwheel --output-dir wheelhouse | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
build-source-dist: | |
name: Build source dist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: "3.10" | |
- name: Build dist | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine numpy meson | |
meson setup build | |
meson dist -C build | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: build/meson-dist/*.tar.gz | |
publish: | |
needs: [build-wheels, build-source-dist] | |
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: [3.10] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Download builds | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.pypi_password }} |