Skip to content

Commit fb37f15

Browse files
authored
Add Github Action to build wheels (#8)
1 parent a9f4187 commit fb37f15

File tree

5 files changed

+149
-7
lines changed

5 files changed

+149
-7
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v2
23-
- uses: actions/setup-python@v2
23+
- uses: actions/setup-python@v4
2424
with:
25-
python-version: 3
25+
python-version: '3.11'
26+
architecture: 'x64'
2627
- name: Build wheels
2728
uses: messense/maturin-action@v1
2829
with:
2930
target: x86_64
3031
manylinux: auto
31-
args: --release --out dist/ --no-sdist
32+
args: --release --out dist/ --interpreter python3.11
3233
- name: Install built wheel
3334
run: |
3435
pip install canonicaljson-rs --no-index --find-links dist/ --force-reinstall

.github/workflows/build.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Publish wheels
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
pull_request:
8+
paths:
9+
- 'Cargo.toml'
10+
- 'pyproject.toml'
11+
12+
jobs:
13+
build:
14+
# This workflow comes from https://github.com/pydantic/pydantic-core/blob/main/.github/workflows/ci.yml
15+
name: build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux }})
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: windows
21+
ls: dir
22+
target: x86_64
23+
manylinux: auto
24+
python-architecture: x64
25+
interpreter: 3.7 3.8 3.9 3.10 3.11
26+
- os: windows
27+
ls: dir
28+
target: i686
29+
manylinux: auto
30+
python-architecture: x86
31+
interpreter: 3.7 3.8 3.9 3.10 3.11
32+
- os: macos
33+
target: x86_64
34+
manylinux: auto
35+
python-architecture: x64
36+
interpreter: 3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9
37+
- os: macos
38+
target: aarch64
39+
manylinux: auto
40+
python-architecture: x64
41+
interpreter: 3.7 3.8 3.9 3.10 3.11
42+
# Build all manylinux targets on 2_24
43+
# https://github.com/pypa/manylinux#readme
44+
# https://github.com/PyO3/maturin-action/blob/135c746/src/index.ts#L33
45+
- os: ubuntu
46+
target: x86_64
47+
manylinux: 2_24
48+
python-architecture: x64
49+
interpreter: 3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9
50+
- os: ubuntu
51+
target: aarch64
52+
manylinux: 2_24
53+
python-architecture: x64
54+
interpreter: 3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9
55+
- os: ubuntu
56+
target: i686
57+
manylinux: 2_24
58+
python-architecture: x64
59+
interpreter: 3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9
60+
- os: ubuntu
61+
target: armv7
62+
manylinux: 2_24
63+
python-architecture: x64
64+
interpreter: 3.7 3.8 3.9 3.10 3.11
65+
- os: ubuntu
66+
target: ppc64le
67+
manylinux: 2_24
68+
python-architecture: x64
69+
interpreter: 3.7 3.8 3.9 3.10 3.11
70+
- os: ubuntu
71+
target: s390x
72+
manylinux: 2_24
73+
python-architecture: x64
74+
interpreter: 3.7 3.8 3.9 3.10 3.11
75+
# musllinux - https://musl.libc.org/about.html
76+
- os: ubuntu
77+
target: x86_64
78+
manylinux: musllinux_1_1 # /!\ value used in steps conditions below.
79+
python-architecture: x64
80+
interpreter: 3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9
81+
- os: ubuntu
82+
target: aarch64
83+
manylinux: musllinux_1_1
84+
python-architecture: x64
85+
interpreter: 3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9
86+
87+
runs-on: ${{ matrix.os }}-latest
88+
steps:
89+
- uses: actions/checkout@v3
90+
91+
- name: set up python
92+
uses: actions/setup-python@v4
93+
with:
94+
python-version: '3.11'
95+
architecture: ${{ matrix.python-architecture }}
96+
97+
- run: pip install -U twine
98+
99+
- name: build sdist
100+
if: ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux != 'musllinux_1_1' }}
101+
uses: messense/maturin-action@v1
102+
with:
103+
command: sdist
104+
args: --out dist/
105+
rust-toolchain: stable
106+
107+
- name: build wheels
108+
uses: messense/maturin-action@v1
109+
with:
110+
target: ${{ matrix.target }}
111+
manylinux: ${{ matrix.manylinux }}
112+
args: --release --out dist/ --interpreter ${{ matrix.interpreter }}
113+
rust-toolchain: stable
114+
115+
- run: ${{ matrix.ls || 'ls -lh' }} dist/
116+
117+
- run: twine check --strict dist/*
118+
119+
- name: install built wheel
120+
if: ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux != 'musllinux_1_1' }}
121+
run: |
122+
pip install canonicaljson-rs --no-index --find-links dist/ --force-reinstall
123+
python -c "import canonicaljson"
124+
125+
- uses: actions/upload-artifact@v3
126+
with:
127+
name: pypi_files
128+
path: dist/

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/target
2+
/sdist
3+
/PKG-INFO
24
__pycache__
35
.vscode/
46
.venv

README.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,32 @@ In order to install the package in the current environment:
4040
4141
maturin develop
4242
43-
Build and Release:
43+
Release
44+
=======
45+
46+
Update version in ``Cargo.toml`` and:
4447

4548
.. code-block ::
4649
4750
vim Cargo.toml
4851
git ci -am "Bump version"
49-
git tag -a v1.2.3
52+
git tag -a vX.Y.Z
53+
git push vX.Y.Z
5054
51-
Update version in ``Cargo.toml`` and:
55+
Publish wheel for your host OS:
5256

5357
.. code-block ::
5458
5559
maturin build
5660
maturin publish
5761
62+
63+
Publish wheels of all architectures on PyPi:
64+
65+
1. Download artifacts from Github Actions run on tag vX.Y.Z. On the bottom of the `Publish wheels` workflow summary page, download the `pypi_files.zip` and extract it locally.
66+
2. Run `twine check --strict pypi_files/*.whl`
67+
3. Publish on PyPi with `twine upload --skip-existing pypi_files/*.whl`
68+
5869
See Also
5970
========
6071

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["maturin>=0.12,<0.13"]
2+
requires = ["maturin>=0.14,<0.15"]
33
build-backend = "maturin"
44

55
[package.metadata.maturin]

0 commit comments

Comments
 (0)