-
Notifications
You must be signed in to change notification settings - Fork 33
226 lines (210 loc) · 6.31 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
name: Build
on:
pull_request:
push:
branches:
- main
- v2
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [
x86_64-linux-android,
i686-linux-android,
armv7-linux-androideabi,
aarch64-linux-android,
]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: "Cache"
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
./target/${{ matrix.target }}
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
# Install latest cross to mitigate unwind linking issue on android builds.
# See https://github.com/cross-rs/cross/issues/1222
- name: Install rust cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }} --manifest-path xmtp_dh/Cargo.toml --target-dir xmtp_dh/target
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: xmtp_dh/target/${{ matrix.target }}/release/libxmtp_dh.so
retention-days: 1
build-macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
target: [
aarch64-apple-darwin,
x86_64-apple-darwin,
aarch64-apple-ios,
x86_64-apple-ios,
aarch64-apple-ios-sim,
]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: "Cache"
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
./target/${{ matrix.target }}
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Build target
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }} --manifest-path bindings_swift/Cargo.toml --target-dir bindings_swift/target
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: bindings_swift/target/${{ matrix.target }}/release/libxmtp_rust_swift.a
retention-days: 1
kotlin:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
./target/release
key: ${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: x86_64-apple-darwin
- name : Install kotlin
run: brew install ktlint
- name: Generate Bindings
working-directory: xmtp_dh
run: ./gen_kotlin.sh
- name: Upload xmtp_dh.kt
uses: actions/upload-artifact@v3
with:
name: kotlin
path: xmtp_dh/src/uniffi/xmtp_dh/xmtp_dh.kt
retention-days: 1
swift:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
./target/release
key: ${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: x86_64-apple-darwin
- name : Install swift
run: brew install swiftformat
- name: Generate and package bindings
working-directory: bindings_swift
run: make bridge
- name: Upload binding archive
uses: actions/upload-artifact@v3
with:
name: bridge
path: |
bindings_swift/include
bindings_swift/Sources
retention-days: 1
package-swift:
needs: [ build-macos, swift ]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Download libs
uses: actions/download-artifact@v3
with:
path: bindings_swift/build
- name: Build xmtp-rust-swift.zip
working-directory: bindings_swift
run: |
rm -r ./include
mv build/bridge/include .
mv build/bridge/Sources .
make swift
- name: Upload xmtp-rust-swift.zip
uses: actions/upload-artifact@v3
with:
name: xmtp-rust-swift.zip
path: bindings_swift/xmtp-rust-swift.zip
retention-days: 1
package-android:
needs: [ build, kotlin ]
runs-on: ubuntu-latest
steps:
- name: Download libs & bindings
uses: actions/download-artifact@v3
with:
path: .
- name: Build xmtp_dh.zip
run: |
# not sure why we're building this one
# mv aarch64-unknown-linux-gnu/libxmtp_dh.so jniLibs/arm64-v8a/
# mkdir -p jniLibs/x86_64
# mv x86_64-linux-android/libxmtp_dh.so jniLibs/x86_64/
mkdir -p jniLibs/x86
mv i686-linux-android/libxmtp_dh.so jniLibs/x86/
mkdir -p jniLibs/armeabi-v7a
mv armv7-linux-androideabi/libxmtp_dh.so jniLibs/armeabi-v7a/
mkdir -p jniLibs/arm64-v8a
mv aarch64-linux-android/libxmtp_dh.so jniLibs/arm64-v8a/
mkdir -p java
mv kotlin/xmtp_dh.kt java/
zip -r xmtp_dh.zip jniLibs java
- name: Upload xmtp_dh.zip
uses: actions/upload-artifact@v3
with:
name: xmtp_dh.zip
path: xmtp_dh.zip