Skip to content

Commit f29437a

Browse files
authored
Merge pull request #49 from 0x26res/test-maturin-release-script
Use maturin ci
2 parents 5b7bd9d + 2da715b commit f29437a

File tree

3 files changed

+110
-154
lines changed

3 files changed

+110
-154
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: "[ptars] CI"
1+
name: "CI"
22

33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
pull_request:
88

99
jobs:

.github/workflows/release.yaml

+102-152
Original file line numberDiff line numberDiff line change
@@ -1,216 +1,166 @@
1-
name: "[ptars] Release"
1+
# This file is autogenerated by maturin v1.7.0
2+
# To update, run
3+
#
4+
# maturin generate-ci github
5+
#
6+
name: "Wheels"
27

38
on:
49
push:
10+
branches:
11+
- main
512
tags:
6-
- v*
13+
- 'v*'
714

8-
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
cancel-in-progress: true
11-
12-
env:
13-
PACKAGE_NAME: ptars
14-
CARGO_INCREMENTAL: 0
15-
CARGO_NET_RETRY: 10
16-
CARGO_TERM_COLOR: always
17-
RUSTUP_MAX_RETRIES: 10
15+
permissions:
16+
contents: read
1817

1918
jobs:
20-
sdist:
21-
runs-on: ubuntu-latest
19+
linux:
20+
runs-on: ${{ matrix.platform.runner }}
21+
strategy:
22+
matrix:
23+
platform:
24+
- runner: ubuntu-latest
25+
target: x86_64
26+
- runner: ubuntu-latest
27+
target: x86
28+
- runner: ubuntu-latest
29+
target: aarch64
30+
- runner: ubuntu-latest
31+
target: armv7
32+
- runner: ubuntu-latest
33+
target: s390x
34+
- runner: ubuntu-latest
35+
target: ppc64le
2236
steps:
2337
- uses: actions/checkout@v4
2438
- uses: actions/setup-python@v5
2539
with:
26-
python-version: "3.11"
27-
- name: "Build sdist"
40+
python-version: 3.x
41+
- name: Build wheels
2842
uses: PyO3/maturin-action@v1
2943
with:
30-
command: sdist
31-
args: --out dist
32-
- name: "Test sdist"
33-
run: |
34-
tar -ztvf dist/${{ env.PACKAGE_NAME }}-*.tar.gz
35-
pip install dist/${{ env.PACKAGE_NAME }}-*.tar.gz --force-reinstall
36-
python -c "import ptars"
37-
- name: "Upload sdist"
38-
uses: actions/upload-artifact@v3
44+
target: ${{ matrix.platform.target }}
45+
args: --release --out dist --find-interpreter
46+
sccache: 'true'
47+
manylinux: auto
48+
- name: Upload wheels
49+
uses: actions/upload-artifact@v4
3950
with:
40-
name: wheels
51+
name: wheels-linux-${{ matrix.platform.target }}
4152
path: dist
4253

43-
macos:
44-
runs-on: macos-14
54+
musllinux:
55+
runs-on: ${{ matrix.platform.runner }}
4556
strategy:
4657
matrix:
47-
python-version:
48-
- "3.10"
49-
- "3.11"
50-
- "3.12"
58+
platform:
59+
- runner: ubuntu-latest
60+
target: x86_64
61+
- runner: ubuntu-latest
62+
target: x86
63+
- runner: ubuntu-latest
64+
target: aarch64
65+
- runner: ubuntu-latest
66+
target: armv7
5167
steps:
5268
- uses: actions/checkout@v4
5369
- uses: actions/setup-python@v5
5470
with:
55-
python-version: ${{ matrix.python-version }}
56-
- uses: dtolnay/rust-toolchain@stable
57-
with:
58-
targets: aarch64-apple-darwin
59-
- name: Build wheels - universal2
71+
python-version: 3.x
72+
- name: Build wheels
6073
uses: PyO3/maturin-action@v1
6174
with:
62-
args: -i python --release --target=universal2-apple-darwin --out dist
63-
- name: Install build wheel - universal2
64-
run: |
65-
pip install --force-reinstall dist/ptars*_universal2.whl
66-
cd ~ && python -c 'import ptars'
75+
target: ${{ matrix.platform.target }}
76+
args: --release --out dist --find-interpreter
77+
sccache: 'true'
78+
manylinux: musllinux_1_2
6779
- name: Upload wheels
68-
uses: actions/upload-artifact@v3
80+
uses: actions/upload-artifact@v4
6981
with:
70-
name: wheels
82+
name: wheels-musllinux-${{ matrix.platform.target }}
7183
path: dist
84+
7285
windows:
73-
runs-on: windows-latest
86+
runs-on: ${{ matrix.platform.runner }}
7487
strategy:
7588
matrix:
76-
python-version:
77-
- "3.10"
78-
- "3.11"
79-
- "3.12"
80-
target:
81-
- x64
89+
platform:
90+
- runner: windows-latest
91+
target: x64
92+
- runner: windows-latest
93+
target: x86
8294
steps:
8395
- uses: actions/checkout@v4
8496
- uses: actions/setup-python@v5
8597
with:
86-
python-version: ${{ matrix.python-version }}
87-
architecture: ${{ matrix.target }}
88-
- uses: dtolnay/rust-toolchain@stable
98+
python-version: 3.x
99+
architecture: ${{ matrix.platform.target }}
89100
- name: Build wheels
90101
uses: PyO3/maturin-action@v1
91102
with:
92-
target: ${{ matrix.target }}
93-
args: -i python --release --out dist
94-
- name: Install build wheel
95-
shell: bash
96-
run: |
97-
pip install --force-reinstall dist/ptars*.whl
98-
cd ~ && python -c 'import ptars'
103+
target: ${{ matrix.platform.target }}
104+
args: --release --out dist --find-interpreter
105+
sccache: 'true'
99106
- name: Upload wheels
100-
uses: actions/upload-artifact@v3
107+
uses: actions/upload-artifact@v4
101108
with:
102-
name: wheels
109+
name: wheels-windows-${{ matrix.platform.target }}
103110
path: dist
104111

105-
linux:
106-
runs-on: ubuntu-latest
112+
macos:
113+
runs-on: ${{ matrix.platform.runner }}
107114
strategy:
108115
matrix:
109-
python-version:
110-
- "3.10"
111-
- "3.11"
112-
- "3.12"
113-
target: [x86_64, i686]
116+
platform:
117+
- runner: macos-12
118+
target: x86_64
119+
- runner: macos-14
120+
target: aarch64
114121
steps:
115122
- uses: actions/checkout@v4
116-
- uses: dtolnay/rust-toolchain@stable
117123
- uses: actions/setup-python@v5
118124
with:
119-
python-version: ${{ matrix.python-version }}
120-
- name: Build Wheels
125+
python-version: 3.x
126+
- name: Build wheels
121127
uses: PyO3/maturin-action@v1
122128
with:
123-
target: ${{ matrix.target }}
124-
manylinux: auto
125-
args: -i python${{ matrix.python-version }} --release --out dist
126-
- name: Install build wheel
127-
if: matrix.target == 'x86_64'
128-
run: |
129-
pip install --force-reinstall dist/ptars*.whl
130-
cd ~ && python -c 'import ptars'
129+
target: ${{ matrix.platform.target }}
130+
args: --release --out dist --find-interpreter
131+
sccache: 'true'
131132
- name: Upload wheels
132-
uses: actions/upload-artifact@v3
133+
uses: actions/upload-artifact@v4
133134
with:
134-
name: wheels
135+
name: wheels-macos-${{ matrix.platform.target }}
135136
path: dist
136137

137-
linux-cross:
138+
sdist:
138139
runs-on: ubuntu-latest
139-
strategy:
140-
matrix:
141-
python:
142-
[
143-
{ version: "3.10", abi: "cp310-cp310" },
144-
{ version: "3.11", abi: "cp311-cp311" },
145-
{ version: "3.12", abi: "cp312-cp312" },
146-
]
147-
target: # TODO: armv7 not supported by pyarrow yet
148-
- aarch64
149140
steps:
150141
- uses: actions/checkout@v4
151-
- name: Build Wheels
142+
- name: Build sdist
152143
uses: PyO3/maturin-action@v1
153-
env:
154-
PYO3_CROSS_LIB_DIR: /opt/python/${{ matrix.python.abi }}/lib
155144
with:
156-
target: ${{ matrix.target }}
157-
manylinux: auto
158-
args: -i python${{matrix.python.version}} --release --out dist
159-
- uses: uraimo/[email protected]
160-
name: Install build wheel
161-
with:
162-
arch: ${{ matrix.target }}
163-
distro: ubuntu20.04
164-
githubToken: ${{ github.token }}
165-
# Mount the dist directory as /artifacts in the container
166-
dockerRunArgs: |
167-
--volume "${PWD}/dist:/artifacts"
168-
install: |
169-
apt update -y
170-
apt install -y gcc musl-dev python3-dev # this is needed for psutil
171-
apt install -y --no-install-recommends software-properties-common
172-
add-apt-repository ppa:deadsnakes/ppa
173-
apt update -y
174-
PYTHON=python${{ matrix.python.version }}
175-
apt install -y $PYTHON $PYTHON-distutils $PYTHON-venv
176-
run: |
177-
ls -lrth /artifacts
178-
PYTHON=python${{ matrix.python.version }}
179-
$PYTHON --version
180-
$PYTHON -m venv venv
181-
source venv/bin/activate
182-
pip install --upgrade pip setuptools wheel
183-
pip install --force-reinstall dist/ptars*.whl
184-
cd ~ && python -c 'import ptars'
185-
- name: Upload wheels
186-
uses: actions/upload-artifact@v3
145+
command: sdist
146+
args: --out dist
147+
- name: Upload sdist
148+
uses: actions/upload-artifact@v4
187149
with:
188-
name: wheels
150+
name: wheels-sdist
189151
path: dist
190152

191-
upload-release:
192-
name: Upload Release to PyPI
153+
release:
154+
name: Release
193155
runs-on: ubuntu-latest
194-
needs:
195-
- sdist
196-
- macos
197-
- windows
198-
- linux
199-
- linux-cross
156+
if: "startsWith(github.ref, 'refs/tags/')"
157+
needs: [linux, musllinux, windows, macos, sdist]
200158
steps:
201-
- name: Download artifacts
202-
uses: actions/download-artifact@v3
203-
with:
204-
name: wheels
205-
path: wheels
206-
- name: List wheels
207-
shell: bash
208-
run: |
209-
ls -ltr wheels/
210-
- name: Publish to PyPi
211-
uses: pypa/gh-action-pypi-publish@release/v1
159+
- uses: actions/download-artifact@v4
160+
- name: Publish to PyPI
161+
uses: PyO3/maturin-action@v1
162+
env:
163+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
212164
with:
213-
skip-existing: true
214-
packages-dir: wheels
215-
verbose: true
216-
password: ${{ secrets.PYPI_API_TOKEN }}
165+
command: upload
166+
args: --non-interactive --skip-existing wheels-*/*

DEVELOPMENT.md

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ cargo build && maturin develop && RUST_BACKTRACE=1 pytest python/test
3131
- Update the poetry lock file `poetry lock --no-update`
3232
- Tag and push the tag (don't forget to preprend a `v` to the version when tagging)
3333

34+
Note: the ci script is autogenerated:
35+
36+
```shell
37+
maturin generate-ci github > .github/workflows/release.yml
38+
```
39+
3440
## TODO
3541

3642
- [ ] arrow to proto

0 commit comments

Comments
 (0)