forked from zingolabs/zingo-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (197 loc) · 7.93 KB
/
android-build.yaml
File metadata and controls
229 lines (197 loc) · 7.93 KB
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
name: Build
on:
workflow_call:
inputs:
cache-key:
required: true
type: string
arch:
required: true
type: string
env:
CACHE-KEY: ${{ inputs.cache-key }}
ARCH: ${{ inputs.arch }}
REPO-OWNER: ${{ github.repository_owner }}
jobs:
android-check-build-cache:
name: Check build cache
runs-on: macos-15
outputs:
native-cache-found: ${{ steps.native-set-cache-found.outputs.native-cache-found }}
kotlin-cache-found: ${{ steps.kotlin-set-cache-found.outputs.kotlin-cache-found }}
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v5
with:
repository: ${{ env.REPO-OWNER }}/crosslink-mobile-client
- name: Check if native rust cache exists
id: native-check-build-cache
uses: actions/cache/restore@v4
with:
path: android/app/src/main/jniLibs/${{ env.ARCH }}
key: native-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
lookup-only: true
- name: Set cache-found
id: native-set-cache-found
run: echo "native-cache-found=${{ steps.native-check-build-cache.outputs.cache-hit }}" >> $GITHUB_OUTPUT
- name: Check if kotlin uniffi cache exists
id: kotlin-check-build-cache
uses: actions/cache/restore@v4
with:
path: android/app/build/generated/source/uniffi/release/java/uniffi/zingo
key: kotlin-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
lookup-only: true
- name: Set cache-found
id: kotlin-set-cache-found
run: echo "kotlin-cache-found=${{ steps.kotlin-check-build-cache.outputs.cache-hit }}" >> $GITHUB_OUTPUT
android-build:
name: Build native rust & kotlin uniffi
needs: android-check-build-cache
if: ${{ needs.android-check-build-cache.outputs.native-cache-found != 'true' || needs.android-check-build-cache.outputs.kotlin-cache-found != 'true' }}
runs-on: ubuntu-24.04
container:
image: zingodevops/android_builder:017
env:
RUSTUP_HOME: /root/.rustup
steps:
- name: Install libraries
run: |
apt update \
&& apt upgrade -y \
&& apt install -y --no-install-recommends --no-install-suggests \
build-essential \
cmake \
golang \
clang-18 \
libclang-18-dev \
protobuf-compiler \
gcc \
g++
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v5
with:
repository: ${{ env.REPO-OWNER }}/crosslink-mobile-client
- name: Cargo update for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: |
echo "zingolib_ref=$(echo ${GITHUB_REF} | sed 's/\//\\\//g')" >> $GITHUB_ENV
sed -i "/^zingolib/ s/branch = \"dev\"/rev = \"${{ env.zingolib_ref }}\"/" "rust/lib/Cargo.toml"
if cat rust/lib/Cargo.toml | grep "^zingolib" | grep -q "branch"; then exit 1; fi
cd rust
cargo update -p zingolib -p regchest_utils --aggressive
- name: Cargo default stable
run: |
rustup update
rustup upgrade
rustup toolchain install stable --profile minimal --component rust-src
rustup default stable
- name: AWS libcrypto rust building
run: cargo install --force --locked bindgen-cli
- name: Cargo build release
working-directory: ./rust/lib
run: cargo build --release
- name: Cargo uniffi kotlin
working-directory: ./rust/lib
run: |
cargo run --release --features=uniffi/cli --bin uniffi-bindgen \
generate --library ../target/release/libzingo.so --language kotlin \
--out-dir ../../android/app/build/generated/source/uniffi/release/java
- name: Upload kotlin uniffi
uses: actions/upload-artifact@v4
with:
name: kotlin-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
path: android/app/build/generated/source/uniffi/release/java/uniffi/zingo/zingo.kt
- name: Set envs for x86_64
if: ${{ env.ARCH == 'x86_64' }}
run: |
rustup target add x86_64-linux-android
echo "TARGET=x86_64-linux-android" >> $GITHUB_ENV
echo "CC=x86_64-linux-android" >> $GITHUB_ENV
echo "CARGO_FEATURE_STD=false" >> $GITHUB_ENV
- name: Set envs for x86
if: ${{ env.ARCH == 'x86' }}
run: |
rustup target add i686-linux-android
echo "TARGET=i686-linux-android" >> $GITHUB_ENV
echo "CC=i686-linux-android" >> $GITHUB_ENV
echo "CARGO_FEATURE_STD=false" >> $GITHUB_ENV
- name: Set envs for arm64-v8a
if: ${{ env.ARCH == 'arm64-v8a' }}
run: |
rustup target add aarch64-linux-android
echo "TARGET=aarch64-linux-android" >> $GITHUB_ENV
echo "CC=aarch64-linux-android" >> $GITHUB_ENV
echo "CARGO_FEATURE_STD=true" >> $GITHUB_ENV
- name: Set envs for armeabi-v7a
if: ${{ env.ARCH == 'armeabi-v7a' }}
run: |
rustup target add armv7-linux-androideabi
echo "TARGET=armv7-linux-androideabi" >> $GITHUB_ENV
echo "CC=armv7a-linux-androideabi" >> $GITHUB_ENV
echo "CARGO_FEATURE_STD=false" >> $GITHUB_ENV
- name: Cargo NDK
run: cargo install --version 4.0.1 cargo-ndk
- name: Cargo build
working-directory: ./rust/lib
run: |
cargo ndk \
--target ${{ env.TARGET }} build \
--release
env:
AR: llvm-ar
LD: ld
RANLIB: llvm-ranlib
CC: ${{ env.CC }}24-clang
CARGO_FEATURE_STD: ${{ env.CARGO_FEATURE_STD }}
LIBCLANG_PATH: /usr/lib/llvm-18/lib
CARGO_NDK_PLATFORM: 24
CARGO_NDK_ANDROID_PLATFORM: 24
- name: LLVM Strip
working-directory: ./rust/target
run: llvm-strip --strip-all ./${{ env.TARGET }}/release/libzingo.so
- name: LLVM Obj Copy
working-directory: ./rust/target
run: llvm-objcopy --remove-section .comment ./${{ env.TARGET }}/release/libzingo.so
- name: Upload native rust
uses: actions/upload-artifact@v4
with:
name: native-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
path: rust/target/${{ env.TARGET }}/release/libzingo.so
cache-native-android-uniffi:
name: Cache native rust
needs: android-build
runs-on: macos-15
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v5
with:
repository: ${{ env.REPO-OWNER }}/crosslink-mobile-client
- name: Download native rust
uses: actions/download-artifact@v4
with:
name: native-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
path: android/app/src/main/jniLibs/${{ env.ARCH }}
- name: Cache native rust
uses: actions/cache/save@v4
with:
path: android/app/src/main/jniLibs/${{ env.ARCH }}
key: native-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
- name: Download kotlin uniffi
uses: actions/download-artifact@v4
with:
name: kotlin-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}
path: android/app/build/generated/source/uniffi/release/java/uniffi/zingo
- name: Cache kotlin uniffi
uses: actions/cache/save@v4
with:
path: android/app/build/generated/source/uniffi/release/java/uniffi/zingo
key: kotlin-android-uniffi-${{ env.ARCH }}-${{ env.CACHE-KEY }}