-
Notifications
You must be signed in to change notification settings - Fork 71
471 lines (404 loc) · 14.1 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
name: "Indy-VDR"
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 exits for branch or tag)"
required: true
default: false
type: boolean
publish-wrappers:
description: "Publish Wrappers to Registries"
required: true
default: false
type: boolean
jobs:
check:
name: Run Checks
strategy:
matrix:
os: [macos-11, windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
- name: Cargo check
run: cargo check
- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Debug build
run: cargo build --manifest-path libindy_vdr/Cargo.toml --features zmq_vendored
test-suite:
name: Run Test Suite
needs: [check]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
- name: Run local node pool
run: |
docker build -f ci/indy-pool.dockerfile -t test_pool --build-arg pool_ip=10.0.0.2 ci
docker network create --subnet=10.0.0.0/8 indy-sdk-network
docker run -d --name indy_pool -p 9701-9708:9701-9708 --net=indy-sdk-network test_pool
- name: Run tests
run: cargo test --manifest-path libindy_vdr/Cargo.toml --features local_nodes_pool
build-release:
name: Build Library
needs: [check]
strategy:
matrix:
include:
- arch: linux-aarch64
os: ubuntu-latest
lib: libindy_vdr.so
target: aarch64-unknown-linux-gnu
use_cross: true
- arch: linux-x86_64
os: ubuntu-latest
lib: libindy_vdr.so
target: x86_64-unknown-linux-gnu
# using cross here to build against an older glibc for compatibility
use_cross: true
- arch: darwin-universal
os: macos-11
lib: libindy_vdr.dylib
target: apple-darwin
# beta or nightly required for aarch64-apple-darwin target
toolchain: beta
- arch: windows-x86_64
os: windows-latest
lib: indy_vdr.dll
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain || 'stable' }}
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
- if: "!matrix.use_cross"
name: Build library
env:
BUILD_TARGET: ${{ matrix.target }}
BUILD_TOOLCHAIN: ${{ matrix.toolchain || 'stable' }}
BUILD_FEATURES: zmq_vendored
shell: sh
run: ./build.sh
- if: matrix.use_cross
name: Build library (cross)
run: |
cargo install --bins --git https://github.com/rust-embedded/cross --tag v0.2.4 cross
cross build --lib --release --target ${{ matrix.target }} --features zmq_vendored
- name: Upload library artifacts
uses: actions/upload-artifact@v3
with:
name: library-${{ matrix.arch }}
path: target/${{ matrix.target }}/release/${{ matrix.lib }}
- name: Create library 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.arch }}.tar.gz"
- name: Add library 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.arch }}.tar.gz
asset_name: "library-${{ matrix.arch }}.tar.gz"
build-golang:
name: Build and Test Go wrapper
needs: [build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: "Use Golang 1.16.x+"
uses: actions/setup-go@v3
with:
go-version: "^1.16.0"
- name: Fetch library artifacts
uses: actions/download-artifact@v3
with:
name: library-linux-x86_64
- name: Build and test wrapper
run: |
sudo cp libindy_vdr.so /usr/lib/
cd wrappers/golang
go run cmd/demo/demo.go
build-javascript:
name: Build and Test JavaScript wrapper
needs: [build-release]
runs-on: ubuntu-latest
defaults:
run:
working-directory: wrappers/javascript
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node.JS 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Fetch library artifacts
uses: actions/download-artifact@v3
with:
name: library-linux-x86_64
- name: Install dependencies
run: yarn install
- name: Build JavaScript Wrapper
run: yarn build
- name: Lint JavaScript Wrapper
run: yarn lint
- name: Format Check JavaScript Wrapper
run: yarn check-format
- name: Type Check JavaScript Wrapper
run: yarn check-types
- name: Test JavaScript Wrapper
env:
# binary is downloaded to root of repository
LIB_INDY_VDR_PATH: ../../../
run: yarn test
- name: Set NPM config
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-wrappers == 'true')
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "always-auth=true" >> .npmrc
# TODO: this will currently publish the version as defined in the package.json. If the version already
# exists on NPM it will skip the publishing. This means if a new version is released, but the version hasn't been
# updated in the package.json files yet, it won't publish to NPM (which is kinda nice). We should however add a check
# to see if the JS version matches the release version (do we want to keep the js and rust version in sync?)
- name: Publish JavaScript Wrapper
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-wrappers == 'true')
run: npx lerna publish from-package --no-push --no-private --yes --no-git-tag-version
build-ios:
name: Build Library (iOS)
runs-on: macos-latest
strategy:
matrix:
architecture:
[aarch64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-ios]
steps:
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.architecture }}
- run: cargo build --release --target ${{ matrix.architecture }} --package indy-vdr
- name: Save library
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.architecture}}
path: target/${{ matrix.architecture }}/release/libindy_vdr.a
create-ios-xcframework:
name: Create iOS xcframework
runs-on: macos-latest
needs: build-ios
steps:
- uses: actions/checkout@v3
- name: Fetch static libraries
uses: actions/download-artifact@v3
- run: >
lipo -create aarch64-apple-ios-sim/libindy_vdr.a \
x86_64-apple-ios/libindy_vdr.a \
-output libindy_vdr.a
- run: >
xcodebuild -create-xcframework \
-library aarch64-apple-ios/libindy_vdr.a -headers ./libindy_vdr/include/libindy_vdr.h \
-library libindy_vdr.a -headers ./libindy_vdr/include/libindy_vdr.h \
-output output/libindy_vdr.xcframework
- name: Save xcframework
uses: actions/upload-artifact@v3
with:
name: indy_vdr.xcframework
path: output/
- uses: geekyeggo/delete-artifact@v2
with:
name: |
aarch64-apple-ios
aarch64-apple-ios-sim
x86_64-apple-ios
failOnError: false
build-android:
name: Build library (Android)
runs-on: ubuntu-latest
strategy:
matrix:
architecture:
[
aarch64-linux-android,
armv7-linux-androideabi,
i686-linux-android,
x86_64-linux-android,
]
steps:
- uses: actions/checkout@v3
- run: |
cargo install --bins --git https://github.com/rust-embedded/cross --tag v0.2.4 cross
cross build --release --target ${{matrix.architecture}} --package indy-vdr
- name: Save library
uses: actions/upload-artifact@v3
with:
name: ${{matrix.architecture}}
path: target/${{ matrix.architecture }}/release/libindy_vdr.so
create-android-library:
name: Create library (Android)
runs-on: ubuntu-latest
needs: build-android
steps:
- name: Fetch libraries
uses: actions/download-artifact@v3
- run: |
sudo mkdir ./libs
sudo mv aarch64-linux-android ./libs/arm64-v8a
sudo mv armv7-linux-androideabi ./libs/armeabi-v7a
sudo mv i686-linux-android ./libs/x86
sudo mv x86_64-linux-android ./libs/x86_64
- name: Save Android library
uses: actions/upload-artifact@v3
with:
name: android-libraries
path: ./libs
- uses: geekyeggo/delete-artifact@v2
with:
name: |
aarch64-linux-android
armv7-linux-androideabi
i686-linux-android
x86_64-linux-android
failOnError: false
create-ios-android-release-asset:
name: Create iOS and Android Release Assets
runs-on: ubuntu-latest
needs:
- create-ios-xcframework
- create-android-library
if: |
(github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' &&
github.event.inputs.publish == 'true'))
steps:
- name: Fetch Android libraries
uses: actions/download-artifact@v3
with:
name: android-libraries
path: mobile/android/
- name: Fetch iOS Framework
uses: actions/download-artifact@v3
with:
name: indy_vdr.xcframework
path: mobile/ios/
- uses: a7ul/[email protected]
with:
command: c
files: ./mobile
outPath: "library-ios-android.tar.gz"
- name: Add library artifacts to release
uses: svenstaro/upload-release-action@v2
with:
file: library-ios-android.tar.gz
asset_name: "library-ios-android.tar.gz"
build-py:
name: Build and Test Python Wrapper
needs: [build-release]
strategy:
matrix:
arch: [linux-aarch64, linux-x86_64, darwin-universal, windows-x86_64]
python-version: ["3.8"]
include:
- os: ubuntu-latest
arch: linux-aarch64
plat-name: manylinux2014_aarch64
- os: ubuntu-latest
arch: linux-x86_64
plat-name: manylinux2014_x86_64
- os: macos-11
arch: darwin-universal
plat-name: macosx_10_9_universal2 # macosx_10_9_x86_64
- os: windows-latest
arch: windows-x86_64
plat-name: win_amd64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
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@v3
with:
name: library-${{ matrix.arch }}
path: wrappers/python/indy_vdr/
- name: Build python package
shell: sh
run: |
python setup.py bdist_wheel --python-tag=py3 --plat-name=${{ matrix.plat-name }}
working-directory: wrappers/python
- name: Test python package
# FIXME cross platform test the python package
# maybe use the cross docker image?
if: "matrix.arch != 'linux-aarch64'"
shell: sh
run: |
pip install dist/*
python -m demo.test
working-directory: wrappers/python
- if: "runner.os == 'Linux'"
name: Auditwheel
run: auditwheel show wrappers/python/dist/*
- name: Upload python package
uses: actions/upload-artifact@v3
with:
name: python-${{ matrix.arch }}
path: wrappers/python/dist/*
- if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish-wrappers == 'true')
name: Publish python package
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --skip-existing dist/*
working-directory: wrappers/python