-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (180 loc) · 5.36 KB
/
publish.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
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
name: Publish Packages
on:
release:
types: [created]
workflow_dispatch:
inputs:
publish_krec_rust:
description: 'Publish krec package'
type: boolean
default: true
permissions:
contents: read
id-token: write
concurrency:
group: "publish"
cancel-in-progress: true
jobs:
build-wheels:
name: Build ${{ matrix.arch }} wheels
timeout-minutes: 120
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x86_64
skip: "pp* *-musllinux*"
- os: ubuntu-latest
arch: aarch64
skip: "pp* *-musllinux* cp313-*"
- os: macos-latest
arch: arm64
skip: "pp* cp313-*"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Rust target
if: runner.os == 'macOS'
run: |
rustup target add x86_64-apple-darwin
shell: bash
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cibuildwheel
shell: bash
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Cache pip, cibuildwheel and dist
uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.cache/cibuildwheel
dist
key: ${{ runner.os }}-${{ matrix.arch }}-pip-cibw
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-pip-cibw
- name: Install sccache
run: |
cargo install sccache
- name: Build package
env:
CIBW_SKIP: ${{ matrix.skip }}
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_BUILD_VERBOSITY: 1
CARGO_NET_RETRY: 2
RUST_BACKTRACE: 1
RUSTC_WRAPPER: sccache
RUST_LOG: sccache=debug
CIBW_BEFORE_ALL_LINUX: >
yum install -y libudev-devel pkgconfig python3-devel python3-pip python3-wheel &&
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
CIBW_BEFORE_BUILD: pip install setuptools-rust
CIBW_ENVIRONMENT: PATH="/usr/local/bin:$HOME/.cargo/bin:$PATH" CARGO_NET_GIT_FETCH_WITH_CLI=true
run: |
cibuildwheel --output-dir dist
- name: Upload wheel artifacts
uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.arch }}
path: |
dist/*.whl
build-source-dist:
name: Build and publish Python package (source distribution)
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
shell: bash
- name: Build source distribution
run: |
python -m build --sdist --outdir dist
- name: Upload source distribution
uses: actions/upload-artifact@v3
with:
name: source-dist
path: |
dist/*.tar.gz
publish-wheels:
needs: [build-wheels, build-source-dist]
name: Publish Python wheels
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Download all wheels
uses: actions/download-artifact@v3
with:
path: dist
- name: Move wheels to dist directory
run: |
mkdir -p final_dist
find dist -name "*.whl" -exec mv {} final_dist/ \;
find dist -name "*.tar.gz" -exec mv {} final_dist/ \;
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: final_dist/
publish-rust:
name: Build and publish Rust package
timeout-minutes: 10
runs-on: ubuntu-latest
if: ${{ inputs.publish_krec_rust }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev pkg-config
- name: Install protoc
uses: arduino/setup-protoc@v3
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry
restore-keys: |
${{ runner.os }}-cargo-registry
- name: Cache Cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index
restore-keys: |
${{ runner.os }}-cargo-index
- name: Publish K-Rec package to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish -p krec