-
Notifications
You must be signed in to change notification settings - Fork 1
244 lines (204 loc) · 6.7 KB
/
release-python.yml
File metadata and controls
244 lines (204 loc) · 6.7 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
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
name: Publish Python Package
on:
workflow_dispatch:
inputs:
dry-run:
description: Dry run (skip publish)
type: boolean
default: true
toolchain:
description: Select the toolchain to build with
type: choice
options:
- stable
- beta
- nightly
default: stable
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.9'
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
jobs:
validate-version:
name: Validate Branch or Tag
runs-on: ubuntu-latest
steps:
- name: Validate Version Pattern
id: validate
run: |
echo "Checking branch or tag: ${{ github.ref_name }}"
if [[ "${{ github.ref_name }}" =~ ^py-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "✅ Valid version pattern."
else
echo "❌ Version pattern mismatch! Expected: rs-v[0-9]+\.[0-9]+\.[0-9]+"
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Version Match
run: |
cd crates/imgddpy
VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "imgddpy") | .version')
EXPECTED_VERSION="py-v$VERSION"
CURRENT_BRANCH="${{ github.ref_name }}"
if [ "$EXPECTED_VERSION" = "$CURRENT_BRANCH" ]; then
echo "✅ Version matches the branch/tag: $CURRENT_BRANCH"
else
echo "❌ Version mismatch! Expected: $EXPECTED_VERSION, Found: $CURRENT_BRANCH"
exit 1
fi
coverage:
uses: ./.github/workflows/coverage.yml
needs: validate-version
with:
branch: ${{ github.ref_name }}
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
integration-tests:
uses: ./.github/workflows/integration.yml
needs: validate-version
with:
branch: ${{ github.ref_name }}
create-sdist:
needs: [coverage, integration-tests]
name: Build and Test Source Distributions
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.toolchain }}
override: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install maturin
run: pip install maturin
- name: Build source distribution
run: |
maturin sdist --manifest-path crates/imgddpy/Cargo.toml
ls -l target/wheels/
- name: Test source distribution
run: |
pip install --force-reinstall --verbose target/wheels/*.tar.gz
python -c 'import imgdd'
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist-${{ github.run_id }}
path: target/wheels/*.tar.gz
overwrite: true
build-wheels:
needs: [coverage, integration-tests]
name: Build Wheels
strategy:
fail-fast: false
matrix:
include:
# Linux (x64 and ARM)
- os: ubuntu-latest
compatibility: manylinux_2_34
- os: ubuntu-22.04-arm
compatibility: manylinux_2_34
- os: ubuntu-latest
compatibility: musllinux_1_2
- os: ubuntu-22.04-arm
compatibility: musllinux_1_2
# macOS (x64 and ARM)
- os: macos-latest # ARM
compatibility: none
- os: macos-13 # x64
compatibility: none
# Windows (x64 only)
- os: windows-latest
compatibility: none
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.toolchain }}
override: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install maturin
run: pip install maturin
- name: Prepare Rust target (Linux x64 only)
if: matrix.os == 'ubuntu-latest'
run: |
if [ "${{ matrix.compatibility }}" == "musllinux_1_2" ]; then
rustup target add x86_64-unknown-linux-musl
elif [ "${{ matrix.compatibility }}" == "manylinux_2_34" ]; then
rustup target add x86_64-unknown-linux-gnu
fi
- name: Build wheel (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
maturin build --release --manifest-path crates/imgddpy/Cargo.toml --compatibility ${{ matrix.compatibility }}
ls -l target/wheels/
- name: Build wheel (macOS/Windows)
if: matrix.compatibility == 'none'
run: |
maturin build --release --manifest-path crates/imgddpy/Cargo.toml
ls -l target/wheels/
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheels-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.compatibility }}
path: target/wheels/*.whl
overwrite: true
publish-to-pypi:
needs: [create-sdist, build-wheels]
name: Publish to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
if: ${{ !inputs.dry-run }}
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: root
- name: Merge all wheels and source distributions into `output/`
run: |
mkdir -p output
# Move all wheel and sdist files from any artifact subfolder into output/
find root -type f -name "*.whl" -exec mv {} output/ \;
find root -type f -name "*.tar.gz" -exec mv {} output/ \;
ls -l output/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
packages-dir: output
dry-run-check:
needs: [create-sdist, build-wheels]
name: Dry Run
runs-on: ubuntu-latest
if: ${{ inputs.dry-run }}
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: root
- name: Merge all wheels and source distributions into `output/`
run: |
mkdir -p output
find root -type f -name "*.whl" -exec mv {} output/ \;
find root -type f -name "*.tar.gz" -exec mv {} output/ \;
ls -l output/
- name: Dry run output
run: |
echo "Dry run completed. Artifacts are built and available:"
ls -l output/