-
Notifications
You must be signed in to change notification settings - Fork 49
195 lines (169 loc) · 5.98 KB
/
ci-wheels.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Reference:
# - https://github.com/actions/checkout
# - https://github.com/actions/download-artifact
# - https://github.com/actions/upload-artifact
# - https://github.com/pypa/cibuildwheel
# - https://github.com/pypa/build
# - https://github.com/pypa/gh-action-pypi-publish
# - https://test.pypi.org/help/#apitoken
name: ci-wheels
on:
pull_request:
push:
tags:
- "v*"
branches-ignore:
- "conda-lock-auto-update"
- "pre-commit-ci-update-config"
- "dependabot/*"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_bdist:
name: "Build ${{ matrix.os }} (${{ matrix.arch }}) wheels"
# TBD: extend to support windows
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "macos-13"]
arch: ["x86_64", "arm64"]
include:
- os: ubuntu-latest
arch: x86_64
incdir: /usr/include/udunits2
libdir: /usr/lib64
xml_path: /usr/share/udunits/udunits2.xml
- os: macos-13
arch: x86_64
incdir: /usr/local/Cellar/udunits/2.2.28/include
libdir: /usr/local/Cellar/udunits/2.2.28/lib
xml_path: /usr/local/Cellar/udunits/2.2.28/share/udunits/udunits2-common.xml
- os: macos-latest
arch: arm64
incdir: /opt/homebrew/Cellar/udunits/2.2.28/include
libdir: /opt/homebrew/Cellar/udunits/2.2.28/lib
xml_path: /opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-common.xml
- os: "windows-latest"
arch: "AMD64"
xml_path: 'C:\Users\runneradmin\miniconda3\envs\build\Library\share\udunits\udunits2.xml'
incdir: 'C:\Users\runneradmin\miniconda3\envs\build\Library\include'
libdir: 'C:\Users\runneradmin\miniconda3\envs\build\Library\lib'
exclude:
- os: "ubuntu-latest"
arch: "arm64"
- os: "macos-latest"
arch: "x86_64"
- os: "macos-13"
arch: "arm64"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Set MACOSX_DEPLOYMENT_TARGET"
if: startsWith(matrix.os, 'macos')
run: echo "MACOSX_DEPLOYMENT_TARGET=$([[ ${{ matrix.os }} == 'macos-latest' ]] && echo '14.0' || echo '13.0')" >> $GITHUB_ENV
- name: "Conda install"
if: runner.os == 'Windows'
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
channels: conda-forge
activate-environment: build
auto-update-conda: true
conda-remove-defaults: true
- name: "install udunits2 for windows"
if: runner.os == 'Windows'
run: conda install udunits2
- name: "Building ${{ matrix.os }} (${{ matrix.arch }}) wheels"
uses: pypa/[email protected]
env:
CIBW_SKIP: "cp39-* pp* *-musllinux*"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD_FRONTEND: build
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_BUILD_LINUX: yum install -y udunits2-devel
CIBW_BEFORE_BUILD_MACOS: brew install udunits
CIBW_BEFORE_BUILD_WINDOWS: python -m pip install delvewheel
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: >
python -c 'import cf_units; print(f"cf-units v{cf_units.__version__}")' &&
python -m pytest --pyargs cf_units
CIBW_TEST_COMMAND_WINDOWS: python -m pytest --pyargs cf_units
UDUNITS2_INCDIR: ${{ matrix.incdir }}
UDUNITS2_LIBDIR: ${{ matrix.libdir }}
UDUNITS2_XML_PATH: ${{ matrix.xml_path }}
CIBW_ENVIRONMENT_PASS_LINUX: UDUNITS2_INCDIR UDUNITS2_LIBDIR UDUNITS2_XML_PATH
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
delvewheel repair -v
--add-path=C:\Users\runneradmin\miniconda3\envs\build\Library\lib
--add-path=C:\Users\runneradmin\miniconda3\envs\build\Library\bin
--wheel-dir={dest_dir}
{wheel}
- uses: actions/upload-artifact@v4
with:
name: pypi-artifacts-bdist-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ github.workspace }}/wheelhouse/*.whl
build_sdist:
name: "Build sdist"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Building sdist"
shell: bash
run: |
pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: pypi-artifacts-sdist
path: ${{ github.workspace }}/dist/*.tar.gz
show-artifacts:
needs: [build_bdist, build_sdist]
name: "Show artifacts"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/dist
merge-multiple: true
- shell: bash
run: |
ls -l ${{ github.workspace }}/dist
publish-artifacts-test-pypi:
needs: [build_bdist, build_sdist]
name: "Publish to Test PyPI"
runs-on: ubuntu-latest
# upload to Test PyPI for every commit on main branch
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/dist
merge-multiple: true
- 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: true
print_hash: true
publish-artifacts-pypi:
needs: [build_bdist, build_sdist]
name: "Publish to PyPI"
runs-on: ubuntu-latest
# upload to PyPI for every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true