-
Notifications
You must be signed in to change notification settings - Fork 11
244 lines (243 loc) · 9.6 KB
/
releases-android-binary.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
name: Build Artifacts (Android Binary)
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
pull_request:
branches: [master, develop]
paths-ignore:
- '**/*.md'
- '.circleci/**'
- '.cirrus.yml'
push:
branches: [master, develop]
paths-ignore:
- '**/*.md'
- '.circleci/**'
- '.cirrus.yml'
release:
types: [published]
schedule:
- cron: '0 16 * * *'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
env:
CACHE_EPOCH: 131-1
GOPROXY: direct
jobs:
android-binary-release:
strategy:
fail-fast: false
matrix:
include:
- arch: x86
build_type: Release
qemu_suffix: i386
rust_target: i686-linux-android
apilevel: 24
- arch: x64
build_type: Release
qemu_suffix: amd64
rust_target: x86_64-linux-android
apilevel: 24
- arch: arm
build_type: Release
qemu_suffix: armel
rust_target: armv7-linux-androideabi
apilevel: 24
- arch: arm64
build_type: Release
qemu_suffix: aarch64
rust_target: aarch64-linux-android
apilevel: 24
runs-on: ubuntu-20.04
env:
ARCH: ${{ matrix.arch }}
BUILD_TYPE: ${{ matrix.build_type }}
SYSROOT: ${{ github.workspace }}/android-sysroot-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Checkout with shallow submodules
run: |
# unshallow must come first otherwise submodule may be get unshallowed
git fetch --tags --unshallow
git submodule update --init --depth 1
- name: Patch libcxxabi for both of armel and armhf
if: ${{ matrix.arch == 'armel' || matrix.arch == 'arm' }}
run: |
cd third_party/libc++abi
patch -p1 < v8-6.7.17-fix-gcc-unwind-header.patch
- name: Cache toolchain
id: toolchain-cache
uses: actions/cache@v4
with:
path: |
third_party/llvm-build/Release+Asserts
key: ${{ runner.os }}-toolchain-${{ hashFiles('CLANG_REVISION') }}-v${{ env.CACHE_EPOCH }}
- name: Cache tun2proxy build stage
id: tun2proxy-cache
uses: actions/cache@v4
with:
path: |
third_party/tun2proxy/target/${{ matrix.rust_target }}/release/libtun2proxy.a
key: ${{ runner.os }}-rust-${{ matrix.rust_target }}-tun2proxy-${{ hashFiles('RUST_REVISION') }}-${{ hashFiles('RUST_CARGO_REVISION') }}-${{ hashFiles('third_party/tun2proxy/Cargo.toml') }}-v${{ env.CACHE_EPOCH }}-v1
- name: Cache crashpad build stage
id: crashpad-cache
uses: actions/cache@v4
with:
path: |
third_party/crashpad
key: ${{ runner.os }}-android-${{ matrix.arch }}-crashpad-${{ hashFiles('CRASHPAD_COMMIT') }}-v${{ env.CACHE_EPOCH }}-16k-alignment-no-stripped
- name: Cache gradle
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('android/gradle/wrapper/*') }}-${{ hashFiles('android/**/*.gradle') }}
- name: Cache qemu-user
id: qemu-user-cache
uses: actions/cache@v4
with:
path: |
qemu-user*.deb
key: ${{ runner.os }}-qemu-9.1.0-ds-8
- name: Cache sysroot
id: sysroot-cache
uses: actions/cache@v4
with:
path: |
${{ env.SYSROOT }}
key: android-sysroot-${{ matrix.arch }}-v1
- uses: actions/setup-go@v5
with:
go-version: '>=1.20.0'
cache-dependency-path: |
tools/go.sum
third_party/boringssl/src/go.sum
- name: Build build tool
run: |
cd tools
go build
#- uses: actions/setup-java@v4
# with:
# distribution: 'temurin'
# java-version: '17'
- name: Replace JAVA_HOME (pin to java 17)
run: |
echo "JAVA_HOME=${JAVA_HOME_17_X64}" >> $GITHUB_ENV
- name: Replace Android NDK (pin to r26c)
run: |
echo "ANDROID_NDK_VER=26.3.11579264" >> $GITHUB_ENV
- name: "Install dependency: prebuilt clang and clang-tidy binaries"
if: ${{ steps.toolchain-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/download-clang-prebuilt-binaries.py
rm -f third_party/llvm-build/Release+Asserts/*.tgz
- name: "Install dependency: qemu user cache"
if: ${{ steps.qemu-user-cache.outputs.cache-hit != 'true' }}
run: |
wget http://ftp.us.debian.org/debian/pool/main/q/qemu/qemu-user_9.1.0+ds-8_amd64.deb
- name: Change ubuntu mirror
run: |
sudo sed -i 's/azure.archive.ubuntu.com/azure.archive.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update -qq
- name: Populate depedencies
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build pkgconf gettext bubblewrap
# libc6-i386 interferes with x86 build
sudo apt remove libc6-i386
sudo dpkg -i qemu-user_*.deb
- name: Populate dependencie (cmake, overwrite)
run: |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.29.8/cmake-3.29.8-linux-x86_64.tar.gz
sudo tar -C /usr/local --strip-components=1 -xf cmake-3.29.8-linux-x86_64.tar.gz
cmake --version
rm -f *.tar.gz
- name: Build Binary (tun2proxy)
if: ${{ steps.tun2proxy-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/setup-android-rust.sh
WITH_OS=android WITH_CPU=${{ matrix.arch }} ./scripts/build-tun2proxy.sh
- name: Build Binary (prebuild stage for crashpad)
if: ${{ steps.crashpad-cache.outputs.cache-hit != 'true' }}
run: |
# FIXME required by next step, need to copy to current clang with ndk's libunwind.a
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-no-build -no-configure
- name: Build Binary (crashpad)
if: ${{ steps.crashpad-cache.outputs.cache-hit != 'true' }}
run: |
WITH_OS=android WITH_CPU=${{ matrix.arch }} SKIP_STRIP=1 ./scripts/build-crashpad.sh
- name: Build Binary
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-build-benchmark -build-test -nc -no-packaging
- name: "Install dependency: android sysroot (test purpose)"
if: ${{ steps.sysroot-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/get-android-sys.sh ${{ matrix.arch }} "${{ matrix.SYSROOT }}"
- name: Run tests (x86 and x64)
if: ${{ matrix.arch == 'x86' || matrix.arch == 'x64' }}
run: |
# android sysimg doesn't like resolv.conf
mkdir -p $SYSROOT/etc/ssl/certs $SYSROOT/dev $SYSROOT/proc $SYSROOT/data/local/tmp
bwrap --die-with-parent --ro-bind $SYSROOT / \
--ro-bind /sys /sys \
--ro-bind /etc/ssl/certs /etc/ssl/certs \
--proc /proc --dev /dev \
--unshare-all --share-net \
--bind $PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }} /data/local/tmp \
/data/local/tmp/yass_test
- name: Run tests (non x86, under qemu emulation)
if: ${{ matrix.arch != 'x86' && matrix.arch != 'x64' }}
run: |
# TMPDIR is required by leveldb unittests
qemu-${{ matrix.qemu_suffix }} -L $SYSROOT \
-E TMPDIR=$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }} \
$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }}/yass_test
- name: Install the Release certificate
if: ${{ github.event_name == 'release' }}
env:
SIGNING_STORE_BASE64: ${{ secrets.SIGNING_STORE_BASE64 }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: |
echo -n "$SIGNING_STORE_BASE64" | base64 --decode > $RUNNER_TEMP/release.jks
echo "SIGNING_STORE_PATH=$RUNNER_TEMP/release.jks" >> $GITHUB_ENV
echo "SIGNING_STORE_PASSWORD=$SIGNING_STORE_PASSWORD" >> $GITHUB_ENV
echo "SIGNING_KEY_ALIAS=$SIGNING_KEY_ALIAS" >> $GITHUB_ENV
echo "SIGNING_KEY_PASSWORD=$SIGNING_KEY_PASSWORD" >> $GITHUB_ENV
- name: Build AAB bundle
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-build-benchmark -build-test -nc -android-aab
- name: Build APK package
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-build-benchmark -build-test -nc
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
if [ ! -z $SIGNING_STORE_PATH ]; then
rm -f $SIGNING_STORE_PATH
fi
- name: Upload dist tarball (including debuginfo)
if: ${{ github.event_name == 'release' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} yass*.tgz yass*.apk yass*.aab yass*.aab.idsig