Repository navigation
172 lines (162 loc) · 6.45 KB
/
Copy pathpython.yml
File metadata and controls
172 lines (162 loc) · 6.45 KB
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
name: Python package
# The `rustgis` package on PyPI (apps/rustgis-python): tested on every change to it or the
# engine; wheels for every platform built on each published release, attached to it and
# uploaded to PyPI with trusted publishing (the `pypi` environment, no token). The package's
# version is the workspace's, so each release's wheels carry its tag's version.
#
# Pull requests test on Linux; macOS and Windows on main, by hand and for releases, and for a
# pull request labelled `ci:macos`, `ci:windows` or `ci:full` (adding the label runs that platform
# straight away, in ci-label.yml; later pushes include it here).
on:
push:
branches: [main]
pull_request:
paths:
- "apps/rustgis-python/**"
- "crates/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/python.yml"
- ".github/workflows/test-python.yml"
- ".github/scripts/platforms.sh"
release:
types: [published]
workflow_dispatch:
# A new push to a pull request replaces its earlier run. Runs on main, by hand and for releases
# are never cancelled: a merge landing mid-build must not stop the wheels being built.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-${{ github.event_name != 'pull_request' && github.run_id || 'pr' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
jobs:
plan:
name: Platforms
runs-on: ubuntu-latest
outputs:
os: ${{ steps.os.outputs.os }}
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: .github/scripts
- id: os
env:
EVENT: ${{ github.event_name }}
ACTION: ${{ github.event.action }}
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: echo "os=$(.github/scripts/platforms.sh)" >> "$GITHUB_OUTPUT"
test:
needs: plan
uses: ./.github/workflows/test-python.yml
with:
os: ${{ needs.plan.outputs.os }}
wheels:
name: Wheels (${{ matrix.platform.name }})
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- { name: linux-x86_64, runner: ubuntu-latest, target: x86_64, manylinux: "2_28" }
- { name: linux-aarch64, runner: ubuntu-22.04-arm, target: aarch64, manylinux: "2_28" }
- { name: macos-x86_64, runner: macos-15-intel, target: x86_64 }
- { name: macos-aarch64, runner: macos-latest, target: aarch64 }
- { name: windows-x86_64, runner: windows-latest, target: x64 }
steps:
- uses: actions/checkout@v7
- uses: PyO3/maturin-action@v1
with:
working-directory: apps/rustgis-python
target: ${{ matrix.platform.target }}
manylinux: ${{ matrix.platform.manylinux || 'auto' }}
args: --release --locked --out dist
- uses: actions/setup-python@v7
with:
python-version: "3.14"
# Each runner builds for its own architecture, so the wheel installs and runs here.
- name: Smoke-test the wheel
shell: bash
run: |
python -m pip install --no-index --find-links apps/rustgis-python/dist rustgis
python -c "import rustgis; s = rustgis.Session(sample=True); assert s.layers() and s.to_png(width=64, height=32)"
- uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.platform.name }}
path: apps/rustgis-python/dist
# On every change too: the sdist carries the workspace crates it builds from, and a missing
# one would otherwise only show at release time.
sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
# Only main saves the cache (see test-rust.yml).
save-if: ${{ github.ref == 'refs/heads/main' }}
# The Python package ships a copy of the license (pyproject.toml's license-files can't
# reach the repository root).
- name: The license copy matches LICENSE
run: cmp LICENSE apps/rustgis-python/LICENSE || { echo "::error::apps/rustgis-python/LICENSE differs from LICENSE."; exit 1; }
- uses: PyO3/maturin-action@v1
with:
working-directory: apps/rustgis-python
command: sdist
args: --out dist
- uses: actions/setup-python@v7
with:
python-version: "3.14"
- name: Build and test from the sdist alone
shell: bash
run: |
mkdir -p /tmp/sdist-check
cp apps/rustgis-python/dist/*.tar.gz apps/rustgis-python/tests/test_session.py /tmp/sdist-check/
cd /tmp/sdist-check
# conda-forge and other repackagers need the license in the sdist.
# PyPI rejects an sdist whose PKG-INFO License-File isn't at its root.
tar tzf ./*.tar.gz | grep -E '^[^/]+/LICENSE$' || { echo "::error::The sdist has no LICENSE file at its root."; exit 1; }
tar tzf ./*.tar.gz | grep -E '^[^/]+/THIRD-PARTY-LICENSES.txt$' || { echo "::error::The sdist has no THIRD-PARTY-LICENSES.txt at its root."; exit 1; }
python -m pip install ./*.tar.gz pytest
python -m pytest -q test_session.py
- uses: actions/upload-artifact@v7
with:
name: wheels-sdist
path: apps/rustgis-python/dist
# The wheels and the sdist are attached to the GitHub release too, beside the app's packages.
release-assets:
name: Attach to the release
if: github.event_name == 'release'
needs: [test, wheels, sdist]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Upload
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.release.tag_name }}
run: gh release upload "$TAG" dist/* --clobber -R "$GITHUB_REPOSITORY"
publish:
name: Publish to PyPI
if: github.event_name == 'release'
needs: [test, wheels, sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
pattern: wheels-*
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist