Repository navigation
200 lines (171 loc) · 5.67 KB
/
Copy pathpython-fork-release.yml
File metadata and controls
200 lines (171 loc) · 5.67 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
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
name: Python fork release
on:
push:
tags: ['python-v*']
# Build and smoke-test every wheel without publishing.
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/python-fork-release.yml'
- 'crates/polyglot-sql-python/Cargo.toml'
- 'crates/polyglot-sql-python/pyproject.toml'
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Test Rust library
run: cargo test --lib -p polyglot-sql
wheels-linux:
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: '2014'
args: --profile python_release --out dist --features abi3 --manifest-path crates/polyglot-sql-python/Cargo.toml
sccache: true
- name: Smoke test wheel
if: matrix.target == 'x86_64'
run: |
ls dist/*-abi3-*.whl
python -m pip install --no-index --find-links dist polyglot-sql-chio
python -c "import polyglot_sql; assert polyglot_sql.parse_one('SELECT 1', dialect='postgres')"
- name: Upload wheel
uses: actions/upload-artifact@v7
with:
name: fork-python-wheels-linux-${{ matrix.target }}
path: dist
wheels-macos:
needs: test
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
runner: macos-15-intel
smoke: true
# Cross-compiled on the Intel runner: this repository gets no arm64 macOS runner.
- target: aarch64-apple-darwin
runner: macos-15-intel
smoke: false
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --profile python_release --out dist --features abi3 --manifest-path crates/polyglot-sql-python/Cargo.toml
sccache: true
- name: Smoke test wheel
if: matrix.smoke
run: |
ls dist/*-abi3-*.whl
python -m pip install --no-index --find-links dist polyglot-sql-chio
python -c "import polyglot_sql; assert polyglot_sql.parse_one('SELECT 1', dialect='postgres')"
- name: Check cross-compiled wheel
if: ${{ !matrix.smoke }}
run: |
ls dist/*-abi3-macosx_*_arm64.whl
unzip -l dist/*-abi3-macosx_*_arm64.whl | grep -q 'polyglot_sql/.*\.so$'
- name: Upload wheel
uses: actions/upload-artifact@v7
with:
name: fork-python-wheels-macos-${{ matrix.target }}
path: dist
wheels-windows:
needs: test
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Build wheel
uses: PyO3/maturin-action@v1
env:
SCCACHE_IGNORE_SERVER_IO_ERROR: '1'
with:
target: x86_64-pc-windows-msvc
args: --profile python_release --out dist --features abi3 --manifest-path crates/polyglot-sql-python/Cargo.toml
sccache: true
- name: Smoke test wheel
shell: pwsh
run: |
python -m pip install --no-index --find-links dist polyglot-sql-chio
python -c "import polyglot_sql; assert polyglot_sql.parse_one('SELECT 1', dialect='postgres')"
- name: Upload wheel
uses: actions/upload-artifact@v7
with:
name: fork-python-wheels-windows-x86_64
path: dist
sdist:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Build source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path crates/polyglot-sql-python/Cargo.toml
- name: Upload source distribution
uses: actions/upload-artifact@v7
with:
name: fork-python-sdist
path: dist
publish:
if: github.event_name == 'push'
needs: [wheels-linux, wheels-macos, wheels-windows, sdist]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment:
name: pypi
url: https://pypi.org/p/polyglot-sql-chio
steps:
- uses: actions/download-artifact@v8
with:
pattern: fork-python-*
merge-multiple: true
path: dist
- name: Verify artifact versions
run: |
python - <<'PY'
import os
from pathlib import Path
expected = os.environ["GITHUB_REF_NAME"].removeprefix("python-v")
artifacts = list(Path("dist").iterdir())
if not artifacts:
raise SystemExit("No distribution artifacts found")
invalid = [
path.name
for path in artifacts
if not path.name.startswith(f"polyglot_sql_chio-{expected}-")
and path.name != f"polyglot_sql_chio-{expected}.tar.gz"
]
if invalid:
raise SystemExit(f"Artifact version mismatch: {invalid}")
print(f"Verified {len(artifacts)} artifacts for version {expected}")
PY
- name: Publish Python distribution
uses: pypa/gh-action-pypi-publish@release/v1