Skip to content

Merge pull request #122 from AllenCellModeling/fix/publish-pypi #119

Merge pull request #122 from AllenCellModeling/fix/publish-pypi

Merge pull request #122 from AllenCellModeling/fix/publish-pypi #119

Workflow file for this run

on:
push:
branches:
- main
schedule:
- cron: 0 18 * * 1
workflow_dispatch:
env:
CIBW_TEST_COMMAND: pytest {project}/aicspylibczi/tests
CIBW_TEST_EXTRAS: test
# skip python 3.6, 32-bit builds, and PyPy
CIBW_SKIP: cp36-* cp37-* *-win32 *-manylinux_i686 pp*
name: Python Build Main
jobs:
python-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .[test]
- name: Test with pytest
run: |
pytest --cov-report xml --cov=aicspylibczi aicspylibczi/tests
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .[test]
- name: Lint with flake8
run: |
flake8 aicspylibczi --count --verbose --max-line-length=127 --show-source --statistics
build_sdist:
name: Build SDist
needs: [python-test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: build-sdist
path: dist/*.tar.gz
build_wheels:
name: Wheels on ${{ matrix.cibw-arch }}
needs: [python-test, lint]
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
cibw-arch: manylinux_x86_64
- runs-on: macos-latest
cibw-arch: macosx_x86_64
- runs-on: macos-latest
cibw-arch: macosx_arm64
- runs-on: macos-latest
cibw-arch: macosx_universal2
- runs-on: windows-latest
cibw-arch: win_amd64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_BUILD: "*-${{ matrix.cibw-arch }}"
CIBW_BEFORE_ALL_LINUX: yum install -y zlib-devel libpng-devel
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest {project}/aicspylibczi/tests
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CMAKE_OSX_ARCHITECTURES: ${{ matrix.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.cibw-arch == 'macosx_universal2' && 'arm64;x86_64' || '' }}
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: build-wheels-${{ matrix.cibw-arch }}
path: wheelhouse/*.whl
upload_all:
name: Upload if release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
if: "contains(github.event.head_commit.message, 'Bump version')"
steps:
- uses: actions/setup-python@v5
- uses: actions/download-artifact@v4
with:
pattern: build-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0