-
Notifications
You must be signed in to change notification settings - Fork 23
357 lines (313 loc) · 11.2 KB
/
release.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
name: Release
on:
push:
branches:
- main # just build the sdist & wheel, skip release
tags:
- "v*"
pull_request: # also build on PRs touching files that affect building sdist / wheels
paths:
- ".github/workflows/release.yml"
- "ci/**"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
workflow_dispatch:
# cancel running jobs on new commit to PR
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-sdist:
name: Build pyogrio sdist
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Build a source tarball
run: |
python -m pip install --upgrade pip
python -m pip install build setuptools
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: pyogrio-sdist
path: ./dist/*.tar.gz
retention-days: 5
compression-level: 0
test-sdist:
name: Test sdist
needs: [build-sdist]
runs-on: ubuntu-latest
container:
image: "ghcr.io/osgeo/gdal:ubuntu-small-3.9.2"
steps:
- name: Install packages
run: |
apt-get update && apt-get install -y build-essential python3-dev
- name: Create virtual environment
# install uv and use it to create a virtual environment, then add it to
# environment variables so that it is automatically activated and can be
# used for tests below
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
. $HOME/.cargo/env
uv venv .venv
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Download sdist from artifacts
uses: actions/download-artifact@v4
with:
name: pyogrio-sdist
path: wheelhouse
- name: Build from sdist and install test dependencies
shell: bash
run: |
uv pip install --no-cache wheelhouse/*.tar.gz
uv pip install pytest pandas pyproj shapely>=2
uv pip install --no-deps geopandas
uv pip list
- name: Run tests
shell: bash
# virtual environment is automatically activated
run: |
cd ..
uv run python -c "import pyogrio; print(f'GDAL version: {pyogrio.__gdal_version__}\nGEOS version: {pyogrio.__gdal_geos_version__}')"
uv run python -m pytest --pyargs pyogrio.tests -v
build-wheels-linux:
name: Build wheels on Linux
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
include:
# use manylinux2014 for older glibc platforms until discontinued
- wheel_name: "pyogrio-wheel-linux-manylinux2014_x86_64"
container: "ci/manylinux2014_x86_64-vcpkg-gdal.Dockerfile"
# use manylinux_2_28 for any platforms with glibc>=2.28
- wheel_name: "pyogrio-wheel-linux-manylinux_2_28_x86_64"
container: "ci/manylinux_2_28_x86_64-vcpkg-gdal.Dockerfile"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
buildkitd-flags: --debug
- name: Build Docker image with vcpkg and gdal
# using build-push-action (without push) to make use of cache arguments
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.container }}
tags: manylinux-vcpkg-gdal:latest
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
env:
BUILDKIT_PROGRESS: plain
- name: Build wheels
uses: pypa/[email protected]
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.wheel_name }}
path: ./wheelhouse/*.whl
compression-level: 0
build-wheels-mac-win:
name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: "macos-12"
triplet: "x64-osx-dynamic-release"
arch: x86_64
vcpkg_cache: "/Users/runner/.cache/vcpkg/archives"
vcpkg_logs: "/usr/local/share/vcpkg/buildtrees/**/*.log"
- os: "macos-12"
triplet: "arm64-osx-dynamic-release"
arch: arm64
vcpkg_cache: "/Users/runner/.cache/vcpkg/archives"
vcpkg_logs: "/usr/local/share/vcpkg/buildtrees/**/*.log"
- os: "windows-2019"
triplet: "x64-windows-dynamic-release"
arch: AMD64
# windows requires windows-specific paths
vcpkg_cache: "c:\\vcpkg\\installed"
vcpkg_logs: "c:\\vcpkg\\buildtrees\\**\\*.log"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache vcpkg
uses: actions/cache@v4
id: vcpkgcache
with:
path: |
${{ matrix.vcpkg_cache }}
# bump the last digit to avoid using previous build cache
key: ${{ matrix.os }}-${{ matrix.arch }}-vcpkg-gdal3.9.2-cache0
# MacOS build requires aclocal, which is part of automake, but appears
# to be missing in default image
- name: Reinstall automake
if: runner.os == 'macOS'
run: |
brew reinstall automake
echo $(which aclocal)
- name: Checkout specific version of vcpkg
shell: bash
run: |
cd $VCPKG_INSTALLATION_ROOT
# on mac the clone is not clean, otherwise git pull fails
git reset --hard
# pull specific commit with desired GDAL version
git pull
git checkout 73794ce5f63fd138fab999a22959ca7c6305d93c
- name: Install GDAL
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
shell: bash
run: |
vcpkg install --overlay-triplets=./ci/custom-triplets --feature-flags="versions,manifests" --x-manifest-root=./ci --x-install-root=$VCPKG_INSTALLATION_ROOT/installed
vcpkg list
- name: Upload vcpkg build logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: pyogrio-vcpkg-logs-${{ matrix.triplet }}
path: ${{ matrix.vcpkg_logs }}
- name: Build wheels
uses: pypa/[email protected]
env:
# CIBW needs to know triplet for the correct install path
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
CIBW_ARCHS: ${{ matrix.arch }}
- uses: actions/upload-artifact@v4
with:
name: pyogrio-wheel-${{ matrix.triplet }}
path: ./wheelhouse/*.whl
compression-level: 0
test-wheels:
name: Test wheels on ${{ matrix.os }} (Python ${{ matrix.python-version }})
needs: [build-wheels-linux, build-wheels-mac-win]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
[
"ubuntu-latest",
"ubuntu-20.04",
"windows-latest",
"macos-12",
"macos-latest",
]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: "ubuntu-latest"
artifact: pyogrio-wheel-linux-manylinux2014_x86_64
- os: "ubuntu-latest"
artifact: pyogrio-wheel-linux-manylinux_2_28_x86_64
- os: "ubuntu-20.04"
artifact: pyogrio-wheel-linux-manylinux_2_28_x86_64
- os: "windows-latest"
artifact: pyogrio-wheel-x64-windows-dynamic-release
- os: "macos-12"
artifact: pyogrio-wheel-x64-osx-dynamic-release
- os: "macos-latest"
artifact: pyogrio-wheel-arm64-osx-dynamic-release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Create virtual environment (Linux / MacOS)
# install uv and use it to create a virtual environment, then add it to
# environment variables so that it is automatically activated and can be
# used for tests below
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
. $HOME/.cargo/env
uv venv .venv
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Create virtual environment (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
irm https://astral.sh/uv/install.ps1 | iex
uv venv .venv
"VIRTUAL_ENV=.venv" | Out-File -FilePath $env:GITHUB_ENV -Append
"$PWD/.venv/Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Download wheels from artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: wheelhouse
- name: Install dependencies and pyogrio wheel
shell: bash
run: |
if [ ${{ matrix.python-version }} != "3.13" ]; then
uv pip install -r ci/requirements-wheel-test.txt
else
uv pip install pytest numpy certifi packaging
fi
uv pip install --no-cache --pre --no-index --find-links wheelhouse pyogrio
if [ ${{ matrix.python-version }} != "3.13" ]; then
uv pip install --no-deps geopandas
fi
uv pip list
- name: Run tests
shell: bash
# virtual environment is automatically activated
run: |
cd ..
uv run python -c "import pyogrio; print(f'GDAL version: {pyogrio.__gdal_version__}\nGEOS version: {pyogrio.__gdal_geos_version__}')"
uv run python -m pytest --pyargs pyogrio.tests -v
publish:
name: Publish pyogrio to GitHub / PyPI
needs: [test-sdist, test-wheels]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyogrio
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing to PyPI
contents: write # this permission is required for the Github release action
# release on every tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
pattern: pyogrio-*
path: dist
merge-multiple: true
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
with:
name: Version ${{ github.ref_name }}
tag_name: ${{ github.ref }}
draft: false
prerelease: false
files: dist/*.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}