-
Notifications
You must be signed in to change notification settings - Fork 8
140 lines (117 loc) · 4.15 KB
/
build.yml
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
on:
pull_request:
release:
types:
- published
name: Build
jobs:
# Mostly taken from https://github.com/etesync/etebase-py/blob/ee7bf21e9f57f0ce37f08d1f5cefd8ef0d3bb2f7/.github/workflows/manual.yml
# and https://github.com/Daggy1234/polaroid/blob/ace9a6eee74ee9c30edd0d350d65e2f3b4d8430c/.github/workflows/publish.yml
# See pyproject.toml for configuration.
python-build-wheels:
name: Python wheels (${{ matrix.os }}, ${{ matrix.vers }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: # https://cibuildwheel.readthedocs.io/en/stable/options/#archs
# - vers: aarch64
# os: ubuntu-20.04
- vers: x86_64
os: ubuntu-20.04
- vers: arm64
os: macos-latest
- vers: x86_64
os: macos-latest
- vers: universal2
os: macos-latest
- vers: AMD64
os: windows-2019
# win32: Build fails with error: your Rust target architecture (64-bit) does not match your python interpreter (32-bit)
# - vers: x86
# os: windows-2019
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
# QEMU emulates an arm64 system on X86. This is needed to build the aarch64 wheels
# on GH actions. It's slow. See
# https://github.com/docker/setup-qemu-action/issues/22 and
# https://github.com/pypa/cibuildwheel/issues/598
- name: Set up QEMU
if: runner.os == 'Linux' && matrix.vers == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Install darwin target for apple silicon
if: matrix.vers == 'universal2' || (matrix.vers == 'arm64' && matrix.os == 'macos-latest')
run: rustup target add aarch64-apple-darwin
- name: Setup env when not using docker
if: runner.os != 'Linux'
run: |
python -m pip install --upgrade wheel setuptools setuptools-rust
- name: Install cibuildwheel
run: |
pip install cibuildwheel
- name: Build wheels
run: |
python -m cibuildwheel changeforest-py --archs ${{ matrix.vers }} --output-dir wheelhouse
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
python-build-sdist:
name: Python sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.8'
- name: Install build dependencies
run: python -m pip install numpy maturin
- name: Build sdist
run: maturin sdist -m changeforest-py/Cargo.toml
- uses: actions/upload-artifact@v3
with:
name: wheels
path: changeforest-py/target/wheels/*.tar.gz
upload-testpypi:
needs: [python-build-wheels, python-build-sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TESTPYPI_GH_TOKEN }}
repository_url: https://test.pypi.org/legacy/
upload-pypi:
needs: [python-build-wheels, python-build-sdist, upload-testpypi]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_GH_TOKEN }}
release-crates-io:
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/checkout@v4
- run: cargo login ${CRATES_IO_TOKEN}
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- run: cargo publish