-
Notifications
You must be signed in to change notification settings - Fork 18
274 lines (233 loc) · 8.37 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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: "Indy-Credx"
env:
RUST_VERSION: "1.65.0"
CROSS_VERSION: "0.2.4"
OPENSSL_STATIC: 1
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [created]
workflow_dispatch:
inputs:
publish-binaries:
description: "Publish Binaries to Release (will create a release if no release exists for branch or tag)"
required: true
default: false
type: boolean
publish-wrappers:
description: "Publish Wrappers to Registries"
required: true
default: false
type: boolean
jobs:
checks:
name: Run checks
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: clippy, rustfmt
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
with:
shared-key: deps
cache-on-failure: true
- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Cargo check
run: cargo check --workspace --features vendored
- name: Cargo check no default features
run: cargo check --package indy-data-types --no-default-features
- if: ${{ runner.os == 'Linux' }}
name: Pre-install cross
run: |
cargo install --bins --git https://github.com/rust-embedded/cross --tag v${{ env.CROSS_VERSION }} cross
tests:
name: Run tests
needs: [checks]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
with:
shared-key: deps
save-if: false
- name: Debug build
run: cargo build --all-targets --features vendored
# - name: Test indy-data-types (CL)
# run: cargo test --manifest-path indy-data-types/Cargo.toml --features cl
- name: Test indy-data-types (CL-native)
run: cargo test --manifest-path indy-data-types/Cargo.toml --features cl_native,vendored
- name: Test indy-credx (vendored)
run: cargo test --manifest-path indy-credx/Cargo.toml --features vendored
build-release:
name: Build library
needs: [checks]
strategy:
matrix:
include:
- architecture: linux-aarch64
os: ubuntu-latest
lib: libindy_credx.so
target: aarch64-unknown-linux-gnu
use_cross: true
- architecture: linux-x86_64
os: ubuntu-latest
lib: libindy_credx.so
target: x86_64-unknown-linux-gnu
use_cross: true
- architecture: darwin-universal
os: macos-latest
lib: libindy_credx.dylib
target: darwin-universal
# beta or nightly required for aarch64-apple-darwin target
toolchain: beta
- architecture: windows-x86_64
os: windows-latest
lib: indy_credx.dll
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain || env.RUST_VERSION }}
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
with:
shared-key: deps
save-if: false
- if: ${{ matrix.use_cross }}
name: Build (cross)
run: |
cargo install --bins --git https://github.com/rust-embedded/cross --tag v${{ env.CROSS_VERSION }} cross
cross build --lib --release --package indy-credx --target ${{ matrix.target }} --features vendored
- if: ${{ !matrix.use_cross && matrix.architecture == 'darwin-universal' }}
name: Build (mac)
run: BUILD_FEATURES=vendored ./build-universal.sh
# Requires using the default shell on Windows, otherwise it will complain:
# "This perl implementation doesn't produce Windows like paths"
- if: ${{ !matrix.use_cross && matrix.architecture != 'darwin-universal' }}
name: Build (standard)
run: |
cargo build --lib --release --package indy-credx --target ${{ matrix.target }} --features vendored
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: library-${{ matrix.architecture }}
path: target/${{ matrix.target }}/release/${{ matrix.lib }}
- name: Create artifacts directory
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-binaries == 'true')
run: |
mkdir release-artifacts
cp target/${{ matrix.target }}/release/${{ matrix.lib }} release-artifacts/
- uses: a7ul/[email protected]
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-binaries == 'true')
with:
command: c
cwd: release-artifacts
files: .
outPath: "library-${{ matrix.architecture }}.tar.gz"
- name: Add artifacts to release
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-binaries == 'true')
uses: svenstaro/upload-release-action@v2
with:
file: library-${{ matrix.architecture }}.tar.gz
asset_name: "library-${{ matrix.architecture }}.tar.gz"
build-py:
name: Build and test Python wrapper
needs: [build-release]
strategy:
matrix:
architecture:
[linux-aarch64, linux-x86_64, darwin-universal, windows-x86_64]
python-version: ["3.8"]
include:
- os: ubuntu-latest
architecture: linux-aarch64
plat-name: manylinux2014_aarch64
- os: ubuntu-latest
architecture: linux-x86_64
plat-name: manylinux2014_x86_64
- os: macos-latest
architecture: darwin-universal
plat-name: macosx_10_9_universal2 # macosx_10_9_x86_64
- os: windows-latest
architecture: windows-x86_64
plat-name: win_amd64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine auditwheel
- name: Fetch library artifacts
uses: actions/download-artifact@v4
with:
name: library-${{ matrix.architecture }}
path: wrappers/python/indy_credx/
- name: Build wheel package
shell: sh
run: |
python setup.py bdist_wheel --python-tag=py3 --plat-name=${{ matrix.plat-name }}
working-directory: wrappers/python
- name: Run tests
# FIXME cross platform test the python package
# maybe use the cross docker image?
if: ${{ matrix.architecture != 'linux-aarch64' }}
run: python -m demo.test
working-directory: wrappers/python
env:
no_proxy: "*" # python issue 30385
RUST_BACKTRACE: full
# RUST_LOG: debug
- if: ${{ runner.os == 'Linux' }}
name: Audit wheel
run: |
auditwheel show wrappers/python/dist/* | tee auditwheel.log
grep -q manylinux_2_17_ auditwheel.log
- if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-wrappers == 'true')
name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --skip-existing dist/*
working-directory: wrappers/python