-
Notifications
You must be signed in to change notification settings - Fork 23
361 lines (302 loc) · 9.78 KB
/
cross.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
name: Cross-Compile
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
android:
strategy:
matrix:
include:
- target: x86_64-linux-android
ndk: x86_64
- target: aarch64-linux-android
ndk: arm64-v8a
- target: i686-linux-android
ndk: x86
- target: armv7-linux-androideabi
ndk: armeabi-v7a
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: sudo apt-get update -y
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cargo-ndk
run: cargo install cargo-ndk
- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: cargo ndk -t ${{ matrix.ndk }} build --release
- name: Upload so lib
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/*.so
linux:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
linker: CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc
apt-get: gcc
- target: aarch64-unknown-linux-gnu
linker: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
apt-get: gcc-aarch64-linux-gnu
- target: i686-unknown-linux-gnu
linker: CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=gcc
apt-get: gcc-multilib
- target: armv7-unknown-linux-gnueabihf
linker: CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
apt-get: gcc-arm-linux-gnueabihf
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.apt-get }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: |
export ${{ matrix.linker }}
cargo build --target ${{ matrix.target }} --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/*.so
windows:
strategy:
matrix:
arch: [ x86_64, i686 ]
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.arch }}-pc-windows-msvc
- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: cargo build --target ${{ matrix.arch }}-pc-windows-msvc --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}-pc-windows-msvc
path: target/${{ matrix.arch }}-pc-windows-msvc/release/*.dll
macos:
strategy:
matrix:
include:
- arch: x86_64
runs-on: macos-12
- arch: aarch64
runs-on: macos-latest
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build
env:
RUSTFLAGS: '--cfg surrealdb_unstable'
run: cargo build --target ${{ matrix.arch }}-apple-darwin --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}-apple-darwin
path: target/${{ matrix.arch }}-apple-darwin/release/*.dylib
aggregated-jar:
runs-on: ubuntu-latest
needs:
- android
- windows
- macos
steps:
- name: Install dependencies
run: sudo apt-get update
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 22
- name: Gradle
run: chmod +x gradlew
- name: Create directories for artifacts
run: |
mkdir -p src/main/resources/natives/android_64
mkdir -p src/main/resources/natives/android_32
mkdir -p src/main/resources/natives/android_arm64
mkdir -p src/main/resources/natives/android_arm32
mkdir -p src/main/resources/natives/linux_64
mkdir -p src/main/resources/natives/linux_32
mkdir -p src/main/resources/natives/linux_arm64
mkdir -p src/main/resources/natives/linux_arm32
mkdir -p src/main/resources/natives/osx_64
mkdir -p src/main/resources/natives/osx_arm64
mkdir -p src/main/resources/natives/windows_64
mkdir -p src/main/resources/natives/windows_32
- name: Download Android 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-linux-android
path: src/main/resources/natives/android_64
- name: Download Android 32 intel
uses: actions/download-artifact@v4
with:
name: i686-linux-android
path: src/main/resources/natives/android_32
- name: Download Android 64 arm
uses: actions/download-artifact@v4
with:
name: aarch64-linux-android
path: src/main/resources/natives/android_arm64
- name: Download Android 32 arm
uses: actions/download-artifact@v4
with:
name: armv7-linux-androideabi
path: src/main/resources/natives/android_arm32
- name: Download Linux 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-unknown-linux-gnu
path: src/main/resources/natives/linux_64
- name: Download Linux 32 intel
uses: actions/download-artifact@v4
with:
name: i686-unknown-linux-gnu
path: src/main/resources/natives/linux_32
- name: Download Linux 64 arm
uses: actions/download-artifact@v4
with:
name: aarch64-unknown-linux-gnu
path: src/main/resources/natives/linux_arm64
- name: Download Linux 32 arm
uses: actions/download-artifact@v4
with:
name: armv7-unknown-linux-gnueabihf
path: src/main/resources/natives/linux_arm32
- name: Download Darwin 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-apple-darwin
path: src/main/resources/natives/osx_64
- name: Download Darwin 64 arm
uses: actions/download-artifact@v4
with:
name: aarch64-apple-darwin
path: src/main/resources/natives/osx_arm64
- name: Download Windows 64 intel
uses: actions/download-artifact@v4
with:
name: x86_64-pc-windows-msvc
path: src/main/resources/natives/windows_64
- name: Download Windows 32 intel
uses: actions/download-artifact@v4
with:
name: i686-pc-windows-msvc
path: src/main/resources/natives/windows_32
- name: Build JAR
run: ./gradlew jar
- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: surrealdb
path: build/libs/surrealdb-0.3.0-SNAPSHOT.jar
- name: Linux Integration Test
run: ./gradlew -i integrationTest
integration-tests:
strategy:
matrix:
os: [ macos-12, macos-latest, windows-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
needs:
- aggregated-jar
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 22
- name: Gradle
run: chmod +x gradlew
- name: Create directory build/libs
run: mkdir -p build/libs
- name: Download JAR
uses: actions/download-artifact@v4
with:
name: surrealdb
path: build/libs
- name: Tests
run: ./gradlew -i integrationTest
publish:
needs:
- aggregated-jar
- integration-tests
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 22
- name: Download JAR
uses: actions/download-artifact@v4
with:
name: surrealdb
path: build/libs
- name: Publish Jar (Maven)
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }}
- name: Publish release package
uses: softprops/action-gh-release@v2
if: github.event_name == 'release' && github.event.action == 'created'
with:
name: "Release ${{ github.ref_name }}"
files: |
LICENSE
build/libs/*.jar