Merge branch 'matthewp/issue324' of github.com:UMEP-dev/SUEWS into ma… #717
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 and Publish Python wheels to PyPI and TestPyPI | |
on: | |
push: | |
paths: # Push events containing matching files | |
- "src/suews/**" | |
- "src/supy/**" | |
- "src/supy_driver/**" | |
- ".github/workflows/build-publish_to_pypi.yml" | |
- "test/**" | |
- "pyproject.toml" | |
pull_request: | |
paths: # PR events containing matching files | |
- "src/suews/**" | |
- "src/supy/**" | |
- "src/supy_driver/**" | |
- ".github/workflows/build-publish_to_pypi.yml" | |
- "pyproject.toml" | |
jobs: | |
build_wheels: | |
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }} | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
matrix: | |
buildplat: | |
- [ubuntu-latest, manylinux, x86_64] | |
- [macos-13, macosx, x86_64] | |
- [macos-latest, macosx, arm64] | |
- [windows-2019, win, AMD64] | |
python: ["cp39", "cp310", "cp311", "cp312", "cp313"] | |
# exclude: | |
# - buildplat: [macos-latest, macosx, arm64] | |
# python: ["cp38", "cp39"] | |
fail-fast: false | |
env: | |
IS_32_BIT: ${{ matrix.buildplat[2] == 'x86' }} | |
WHEEL_NAME: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }} | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}* | |
CIBW_ARCHS: ${{ matrix.buildplat[2] }} | |
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS | |
CIBW_BEFORE_ALL_MACOS: > | |
brew install gfortran && | |
brew unlink gfortran && | |
brew link gfortran | |
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" # Use delvewheel on windows | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND_MACOS: "python -m pytest '{project}/test'" | |
CIBW_TEST_COMMAND_LINUX: "python -m pytest '{project}/test'" | |
CIBW_TEST_COMMAND_WINDOWS: "python -m pytest {project}\\test" | |
CIBW_TEST_SKIP: "cp310-macosx_arm64" # skip test on arm64 on python 3.10 - cannot pass the water balance test for unknown reason even though it should be the same as x86_64 | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.buildplat[0] == 'macos-13' && '13.0' || '14.0' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
- name: Setup tmate session for debugging | |
if: failure() | |
uses: mxschmitt/action-tmate@v3 | |
timeout-minutes: 15 | |
- name: upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.WHEEL_NAME }} | |
path: ./wheelhouse/*.whl | |
deploy: | |
name: Publish to (Test)PyPI | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
runs-on: ubuntu-latest | |
needs: | |
- build_wheels | |
# permissions: | |
# id-token: write | |
steps: | |
- name: Download all the built wheels | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist/ | |
merge-multiple: true | |
- name: Setup tmate session for debugging | |
if: failure() | |
uses: mxschmitt/action-tmate@v3 | |
timeout-minutes: 15 | |
- name: Publish distribution to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1.8 | |
with: | |
packages-dir: dist/ | |
verbose: true | |
skip-existing: true | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish distribution to PyPI | |
if: startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1.8 | |
with: | |
packages-dir: dist/ | |
verbose: true | |
skip-existing: true | |
password: ${{ secrets.PYPI_API_TOKEN }} |