Skip to content

Commit 2a80b51

Browse files
Merge pull request #8 from deepsourcelabs/add-workflow-for-build-and-releases
add: workflow for build & releases
2 parents 8a0fe70 + f822643 commit 2a80b51

File tree

3 files changed

+233
-1
lines changed

3 files changed

+233
-1
lines changed
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
name: pydracula
2+
3+
on:
4+
push:
5+
6+
jobs: # credits for workflow from https://github.com/messense/crfs-rs/blob/main/.github/workflows/Python.yml
7+
macos:
8+
runs-on: macos-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-python@v4
12+
with:
13+
python-version: 3.9
14+
architecture: x64
15+
- uses: dtolnay/rust-toolchain@stable
16+
- name: Build wheels - x86_64
17+
uses: PyO3/maturin-action@v1
18+
with:
19+
target: x86_64
20+
args: --release --out dist -m pydracula/Cargo.toml
21+
- name: Install built wheel - x86_64
22+
run: |
23+
pip install ./dist/pydracula-*.whl --force-reinstall
24+
rm -rf dist
25+
python -c "import pydracula; pydracula.Lang"
26+
- name: Build wheels - universal2
27+
uses: PyO3/maturin-action@v1
28+
with:
29+
args: --release --universal2 --out dist -m pydracula/Cargo.toml
30+
- name: Install built wheel - universal2
31+
run: |
32+
pip install ./dist/pydracula-*.whl --force-reinstall
33+
rm -rf dist
34+
python -c "import pydracula; pydracula.Lang"
35+
- name: Upload wheels
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: wheels
39+
path: dist
40+
41+
windows:
42+
runs-on: windows-latest
43+
strategy:
44+
matrix:
45+
target: [x64, x86]
46+
steps:
47+
- uses: actions/checkout@v3
48+
- uses: actions/setup-python@v4
49+
with:
50+
python-version: 3.9
51+
architecture: ${{ matrix.target }}
52+
- uses: dtolnay/rust-toolchain@stable
53+
- name: Build wheels
54+
uses: PyO3/maturin-action@v1
55+
with:
56+
target: ${{ matrix.target }}
57+
args: --release --out dist -m pydracula/Cargo.toml
58+
- name: Install built wheel
59+
run: |
60+
pip install pydracula --no-index --find-links dist --force-reinstall
61+
rmdir -r dist
62+
python -c "import pydracula; pydracula.Lang"
63+
- name: Upload wheels
64+
uses: actions/upload-artifact@v3
65+
with:
66+
name: wheels
67+
path: dist
68+
69+
linux:
70+
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
target: [x86_64, i686]
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-python@v4
77+
with:
78+
python-version: 3.9
79+
architecture: x64
80+
- name: Build wheels
81+
uses: PyO3/maturin-action@v1
82+
with:
83+
target: ${{ matrix.target }}
84+
manylinux: auto
85+
args: --release --out dist -m pydracula/Cargo.toml
86+
- name: Install built wheel
87+
if: matrix.target == 'x86_64'
88+
run: |
89+
pip install ./dist/pydracula-*.whl --force-reinstall
90+
rm -rf dist
91+
python -c "import pydracula; pydracula.Lang"
92+
- name: Upload wheels
93+
uses: actions/upload-artifact@v3
94+
with:
95+
name: wheels
96+
path: dist
97+
98+
linux-cross:
99+
runs-on: ubuntu-latest
100+
strategy:
101+
matrix:
102+
target: [aarch64, armv7, s390x, ppc64le, ppc64]
103+
steps:
104+
- uses: actions/checkout@v3
105+
- uses: actions/setup-python@v4
106+
with:
107+
python-version: 3.9
108+
- name: Build wheels
109+
uses: PyO3/maturin-action@v1
110+
with:
111+
target: ${{ matrix.target }}
112+
manylinux: auto
113+
args: --release --out dist -m pydracula/Cargo.toml
114+
- uses: uraimo/[email protected]
115+
if: matrix.target != 'ppc64'
116+
name: Install built wheel
117+
with:
118+
arch: ${{ matrix.target }}
119+
distro: ubuntu20.04
120+
githubToken: ${{ github.token }}
121+
install: |
122+
apt-get update
123+
apt-get install -y --no-install-recommends python3 python3-pip
124+
pip3 install -U pip
125+
run: |
126+
pip3 install ./dist/pydracula-*.whl --force-reinstall
127+
rm -rf dist
128+
python3 -c "import pydracula; pydracula.Lang"
129+
- name: Upload wheels
130+
uses: actions/upload-artifact@v3
131+
with:
132+
name: wheels
133+
path: dist
134+
135+
musllinux:
136+
runs-on: ubuntu-latest
137+
strategy:
138+
matrix:
139+
target:
140+
- x86_64-unknown-linux-musl
141+
- i686-unknown-linux-musl
142+
steps:
143+
- uses: actions/checkout@v3
144+
- uses: actions/setup-python@v4
145+
with:
146+
python-version: 3.9
147+
architecture: x64
148+
- name: Build wheels
149+
uses: PyO3/maturin-action@v1
150+
with:
151+
target: ${{ matrix.target }}
152+
manylinux: musllinux_1_2
153+
args: --release --out dist -m pydracula/Cargo.toml
154+
- name: Install built wheel
155+
if: matrix.target == 'x86_64-unknown-linux-musl'
156+
uses: addnab/docker-run-action@v3
157+
with:
158+
image: alpine:latest
159+
options: -v ${{ github.workspace }}:/io -w /io
160+
run: |
161+
apk add py3-pip
162+
pip3 install -U pip
163+
pip install ./dist/pydracula-*.whl --force-reinstall
164+
rm -rf dist
165+
python -c "import pydracula; pydracula.Lang"
166+
- name: Upload wheels
167+
uses: actions/upload-artifact@v3
168+
with:
169+
name: wheels
170+
path: dist
171+
172+
musllinux-cross:
173+
runs-on: ubuntu-latest
174+
strategy:
175+
matrix:
176+
platform:
177+
- target: aarch64-unknown-linux-musl
178+
arch: aarch64
179+
- target: armv7-unknown-linux-musleabihf
180+
arch: armv7
181+
steps:
182+
- uses: actions/checkout@v3
183+
- uses: actions/setup-python@v4
184+
with:
185+
python-version: 3.9
186+
- name: Build wheels
187+
uses: PyO3/maturin-action@v1
188+
with:
189+
target: ${{ matrix.platform.target }}
190+
manylinux: musllinux_1_2
191+
args: --release --out dist -m pydracula/Cargo.toml
192+
- uses: uraimo/[email protected]
193+
name: Install built wheel
194+
with:
195+
arch: ${{ matrix.platform.arch }}
196+
distro: alpine_latest
197+
githubToken: ${{ github.token }}
198+
install: |
199+
apk add py3-pip
200+
pip3 install -U pip
201+
run: |
202+
pip install ./dist/pydracula-*.whl --force-reinstall
203+
rm -rf dist
204+
python -c "import pydracula; pydracula.Lang"
205+
- name: Upload wheels
206+
uses: actions/upload-artifact@v3
207+
with:
208+
name: wheels
209+
path: dist
210+
211+
release:
212+
name: Release
213+
runs-on: ubuntu-latest
214+
if: "startsWith(github.ref, 'refs/tags/')"
215+
needs: [ macos, windows, linux, linux-cross, musllinux, musllinux-cross ]
216+
steps:
217+
- uses: actions/download-artifact@v3
218+
with:
219+
name: wheels
220+
- uses: actions/setup-python@v4
221+
with:
222+
python-version: 3.9
223+
- name: Publish to PyPI
224+
env:
225+
TWINE_USERNAME: __token__
226+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
227+
run: |
228+
pip install --upgrade twine
229+
twine upload --skip-existing *

pydracula/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ crate-type = ["cdylib"]
1111

1212
[dependencies.pyo3]
1313
version = "0.18.0"
14-
features = ["extension-module"]
14+
features = ["abi3-py37", "extension-module"]
1515

1616
[dependencies]
1717
dracula = { path = ".." }

pydracula/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["maturin>=0.14,<0.15"]
3+
build-backend = "maturin"

0 commit comments

Comments
 (0)