forked from hyperledger/anoncreds-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (108 loc) · 3.65 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
name: 'Anoncreds'
env:
RUST_VERSION: '1.65.0'
CROSS_VERSION: '0.2.4'
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
jobs:
build-release:
name: Build Library
strategy:
matrix:
include:
- architecture: linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
lib: libanoncreds.so
use_cross: true
- architecture: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
lib: libanoncreds.so
use_cross: true
- architecture: darwin-x86_64
os: macos-latest
target: x86_64-apple-darwin
lib: libanoncreds.dylib
- architecture: darwin-aarch64
os: macos-latest
target: aarch64-apple-darwin
lib: libanoncreds.dylib
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust toolchain
if: "matrix.target != 'darwin-universal'"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
targets: ${{ matrix.target }}
- name: Cache cargo resources
uses: Swatinem/rust-cache@v2
with:
shared-key: deps
save-if: false
- name: Build library for Linux
if: "runner.os == 'Linux'"
run: |
cd uniffi
if [ -n "${{ matrix.use_cross }}" ]; then
cargo install --git https://github.com/cross-rs/cross --tag v${{ env.CROSS_VERSION }} cross
cross build --release --target ${{matrix.target}}
else
cargo build --release --target ${{matrix.target}}
fi
- name: Build library for macOS
if: "runner.os == 'macOS'"
run: |
cd uniffi
if [ "${{ matrix.architecture }}" == "darwin-universal" ]; then
./build-release-apple-universal.sh
else
cargo build --release --target ${{matrix.target}}
fi
- name: Upload library artifacts
uses: actions/upload-artifact@v3
with:
name: library-${{ matrix.architecture }}
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
ls
ls uniffi
cp uniffi/target/${{ matrix.target }}/release/${{ matrix.lib }} release-artifacts/
- name: 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 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.architecture }}.tar.gz
asset_name: 'library-${{ matrix.architecture }}.tar.gz'