forked from elhuhdron/pylibczi
-
Notifications
You must be signed in to change notification settings - Fork 8
137 lines (122 loc) · 3.82 KB
/
py-build-main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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/[email protected]
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