forked from zingolabs/zingo-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (129 loc) · 4.93 KB
/
build.yaml
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
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:
check-build-cache:
name: Check build cache
runs-on: macos-12
outputs:
cache-found: ${{ steps.set-cache-found.outputs.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@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile
- name: Check if native rust cache exists
id: check-build-cache
uses: actions/cache@v4
with:
path: android/app/src/main/jniLibs/${{ env.ARCH }}
key: native-librust-${{ env.ARCH }}-${{ env.CACHE-KEY }}
lookup-only: true
- name: Set cache-found
id: set-cache-found
run: echo "cache-found=${{ steps.check-build-cache.outputs.cache-hit }}" >> $GITHUB_OUTPUT
build:
name: Build native rust
needs: check-build-cache
if: ${{ needs.check-build-cache.outputs.cache-found != 'true' }}
runs-on: ubuntu-22.04
container:
image: zingodevops/android_builder:008
env:
RUSTUP_HOME: /root/.rustup
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@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile
- 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\|^zingoconfig/ s/branch = \"dev\"/rev = \"${{ env.zingolib_ref }}\"/" "rust/lib/Cargo.toml"
if cat rust/lib/Cargo.toml | grep "^zingolib\|^zingoconfig" | grep -q "branch"; then exit 1; fi
cd rust && cargo update -p zingolib -p zingoconfig --aggressive
- name: Set envs for x86_64
if: ${{ env.ARCH == 'x86_64' }}
run: |
echo "TARGET=x86_64-linux-android" >> $GITHUB_ENV
echo "CC=x86_64-linux-android" >> $GITHUB_ENV
echo "OPENSSL_PATH=x86_64" >> $GITHUB_ENV
- name: Set envs for x86
if: ${{ env.ARCH == 'x86' }}
run: |
echo "TARGET=i686-linux-android" >> $GITHUB_ENV
echo "CC=i686-linux-android" >> $GITHUB_ENV
echo "OPENSSL_PATH=x86" >> $GITHUB_ENV
- name: Set envs for arm64-v8a
if: ${{ env.ARCH == 'arm64-v8a' }}
run: |
echo "TARGET=aarch64-linux-android" >> $GITHUB_ENV
echo "CC=aarch64-linux-android" >> $GITHUB_ENV
echo "OPENSSL_PATH=aarch64" >> $GITHUB_ENV
- name: Set envs for armeabi-v7a
if: ${{ env.ARCH == 'armeabi-v7a' }}
run: |
echo "TARGET=armv7-linux-androideabi" >> $GITHUB_ENV
echo "CC=armv7a-linux-androideabi" >> $GITHUB_ENV
echo "OPENSSL_PATH=armv7" >> $GITHUB_ENV
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: Cargo build
working-directory: ./rust/android
run: cargo +nightly build -Z build-std --target ${{ env.TARGET }} --release
env:
AR: llvm-ar
LD: ld
RANLIB: llvm-ranlib
CC: ${{ env.CC }}24-clang
OPENSSL_DIR: /opt/openssl-3.1.3/${{ env.OPENSSL_PATH }}
- name: LLVM Strip
working-directory: ./rust/target
run: llvm-strip ./${{ env.TARGET }}/release/librust.so
- name: Upload native rust
uses: actions/upload-artifact@v4
with:
name: native-librust-${{ env.ARCH }}-${{ env.CACHE-KEY }}
path: rust/target/${{ env.TARGET }}/release/librust.so
cache-native-librust:
name: Cache native rust
needs: build
runs-on: macos-12
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@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile
- name: Download native rust
uses: actions/download-artifact@v4
with:
name: native-librust-${{ env.ARCH }}-${{ env.CACHE-KEY }}
path: android/app/src/main/jniLibs/${{ env.ARCH }}
- name: Cache native rust
uses: actions/cache@v4
with:
path: android/app/src/main/jniLibs/${{ env.ARCH }}
key: native-librust-${{ env.ARCH }}-${{ env.CACHE-KEY }}