Skip to content

pyproject.toml: use static metadata for readme/dependencies #139

pyproject.toml: use static metadata for readme/dependencies

pyproject.toml: use static metadata for readme/dependencies #139

name: Publish πŸ“¦ to PyPI
# Build on every branch push, tag push, and pull request change:
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
build_wheels:
name: Build 🐍 wheels πŸ“¦ on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# skip building wheel for windows as it's not working yet
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, macos-latest, macos-13, macos-14] #windows-2019
toolchain:
- {compiler: gcc, version: 13}
- {compiler: intel, version: '2023.2'}
- {compiler: intel-classic, version: '2021.10'}
- {compiler: nvidia-hpc, version: '23.11'}
include:
- os: ubuntu-latest
toolchain: {compiler: gcc, version: 12}
exclude:
- os: macos-latest
toolchain: {compiler: intel, version: '2023.2'}
- os: macos-latest
toolchain: {compiler: nvidia-hpc, version: '23.11'}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

Check failure on line 40 in .github/workflows/build-and-publish-to-pypi.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-and-publish-to-pypi.yml

Invalid workflow file

You have an error in your yaml syntax on line 40
- name: Set up Fortran
uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
- run: |
${{ env.FC }} --version # environment vars FC, CC, and CXX are set
#${{ steps.setup-fortran.outputs.fc }} ... # outputs work too
#- name: Provide gfortran (macOS)
# if: runner.os == 'macOS'
# run: |
# # https://github.com/actions/virtual-environments/issues/2524
# # https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
# sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
# sudo mkdir /usr/local/gfortran
# sudo ln -s /usr/local/Cellar/gcc@11/*/lib/gcc/11 /usr/local/gfortran/lib
# gfortran --version
#- name: Provide gfortran (Windows)
# if: runner.os == 'Windows'
# uses: msys2/setup-msys2@v2
#- name: Tell distutils to use mingw (Windows)
# if: runner.os == 'Windows'
# run: |
# echo "[build]`ncompiler=mingw32" | Out-File -Encoding ASCII ~/pydistutils.cfg
- name: Build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
# Disable building for PyPy and 32bit.
CIBW_SKIP: pp* *-win32 *-manylinux_i686
# Fix error for python 3.11 on macOS
CIBW_ENVIRONMENT_MACOS: SETUPTOOLS_USE_DISTUTILS=stdlib
# Package the DLL dependencies in the wheel for windows (done by default for the other platforms).
# delvewheel cannot mangle the libraries, stripping does not work.
CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel show {wheel} && delvewheel repair -w {dest_dir} {wheel} --no-mangle-all"
- uses: actions/upload-artifact@v4
with:
name: artifact-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build 🐍 source distribution πŸ“¦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: artifact-source
path: dist/*.tar.gz
upload_pypi:
name: Upload πŸ“¦ to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.repository_owner == 'insarlab' && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
path: dist
pattern: artifact-*
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R dist
- name: Publish developed version πŸ“¦ to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: false
verbose: true
- name: Publish released version πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true