This repository was archived by the owner on Sep 27, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
269 lines (234 loc) · 7.92 KB
/
release.yml
File metadata and controls
269 lines (234 loc) · 7.92 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
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
name: Release
on:
workflow_dispatch:
inputs:
# Latest commit to include with the release. If omitted, use the latest commit on the main branch.
sha:
description: Commit SHA
type: string
# Build binaries, but do not publish to crates.io / GitHub.
dry-run:
description: Dry run
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.8'
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
defaults:
run:
shell: bash
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
is-prerelease: ${{ steps.version.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.sha }}
- name: Get version from Cargo.toml
id: version
run: |
VERSION=$(grep -m 1 -oP 'version = "\K[^"]+' Cargo.toml)
if [[ "$VERSION" == *"-"* ]]; then
IS_PRERELEASE=true
else
IS_PRERELEASE=false
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
create-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.sha }}
# Avoid potential out-of-memory errors
- name: Set swap space for Linux
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Create source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Test sdist
run: |
TOOLCHAIN=$(grep -oP 'channel = "\K[^"]+' rust-toolchain.toml)
rustup default $TOOLCHAIN
pip install --force-reinstall --verbose dist/*.tar.gz
polars --version
python -m polars-cli --version
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*.tar.gz
build-wheels:
needs: get-version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [x86_64, aarch64]
exclude:
- os: windows-latest
arch: aarch64
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.sha }}
# Avoid potential out-of-memory errors
- name: Set swap space for Linux
if: matrix.os == 'ubuntu-latest'
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set Rust target
id: target
run: |
if [ ${{ matrix.os == 'ubuntu-latest'}} = true ]; then
VENDOR_SYS=unknown-linux-gnu
elif [ ${{ matrix.os == 'macos-latest'}} = true ]; then
VENDOR_SYS=apple-darwin
else
VENDOR_SYS=pc-windows-msvc
fi
TARGET=${{ matrix.arch }}-$VENDOR_SYS
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: Add rustup target
run: rustup target add ${{ steps.target.outputs.target }}
- name: Set RUSTFLAGS for x86_64
if: matrix.arch == 'x86_64' && matrix.os != 'macos-latest'
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+avx2,+fma,+bmi1,+bmi2,+lzcnt" >> $GITHUB_ENV
- name: Set RUSTFLAGS for x86_64 MacOS
if: matrix.arch == 'x86_64' && matrix.os == 'macos-latest'
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" >> $GITHUB_ENV
- name: Set jemalloc for aarch64 Linux
if: matrix.arch == 'aarch64' && matrix.os == 'ubuntu-latest'
run: echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ steps.target.outputs.target }}
args: >
--release
--out dist
manylinux: '2_28'
- name: Test wheel
# Only test wheels that match the runner architecture for now
if: (matrix.arch == 'x86_64' && matrix.os != 'macos-latest') || (matrix.arch == 'aarch64' && matrix.os == 'macos-latest')
run: |
pip install dist/*.whl --force-reinstall
polars --version
python -m polars-cli --version
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: dist-wheel-${{ matrix.os }}-${{ matrix.arch }}
path: dist/*.whl
- name: Archive binary
id: archive
run: |
ARCHIVE_FILENAME=polars-cli-${{ needs.get-version.outputs.version }}-${{ steps.target.outputs.target }}.tar.gz
DIR=target/${{ steps.target.outputs.target }}/release
tar czvf $ARCHIVE_FILENAME --directory=$DIR polars
echo "filename=$ARCHIVE_FILENAME" >> $GITHUB_OUTPUT
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ steps.archive.outputs.filename }}
publish-to-pypi:
needs: [create-sdist, build-wheels]
environment:
name: release
url: https://pypi.org/project/polars-cli
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download sdist and wheels
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Publish to PyPI
if: inputs.dry-run == false
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
publish-to-crates-io:
needs: [create-sdist, build-wheels]
environment:
name: release
url: https://crates.io/crates/polars-cli
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.sha }}
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish ${{ inputs.dry-run && '--dry-run' || '' }}
publish-to-github:
needs: [publish-to-pypi, publish-to-crates-io, get-version]
environment:
name: release
url: https://github.com/pola-rs/polars-cli/releases
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.sha }}
- name: Download binaries
uses: actions/download-artifact@v4
with:
pattern: binary-*
path: binaries
merge-multiple: true
- name: Create GitHub release
id: github-release
uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
name: ${{ needs.get-version.outputs.version }}
tag: ${{ needs.get-version.outputs.version }}
version: ${{ needs.get-version.outputs.version }}
prerelease: ${{ needs.get-version.outputs.is-prerelease }}
commitish: ${{ inputs.sha || github.sha }}
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload binaries to GitHub release
run: gh release upload $TAG $FILES --clobber
env:
TAG: ${{ steps.github-release.outputs.tag_name }}
FILES: binaries/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish GitHub release
if: inputs.dry-run == false
run: gh release edit $TAG --draft=false
env:
TAG: ${{ steps.github-release.outputs.tag_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}