-
Notifications
You must be signed in to change notification settings - Fork 11
234 lines (233 loc) · 9.06 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
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: 128-2
GOPROXY: direct
jobs:
android-binary-release:
strategy:
fail-fast: false
matrix:
include:
- arch: x86
qemu_suffix: i386
apilevel: 24
- arch: x64
qemu_suffix: amd64
apilevel: 24
- arch: arm
qemu_suffix: armel
apilevel: 24
- arch: arm64
qemu_suffix: aarch64
apilevel: 24
runs-on: ubuntu-20.04
env:
ARCH: ${{ matrix.arch }}
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 clang
id: clang-cache
uses: actions/cache@v4
with:
path: |
third_party/llvm-build/Release+Asserts
key: ${{ runner.os }}-android-toolchain-${{ hashFiles('CLANG_REVISION') }}-v${{ env.CACHE_EPOCH }}
- name: Cache depot_tools
id: depot-cache
uses: actions/cache@v4
with:
path: |
third_party/depot_tools
key: ${{ runner.os }}-depot_tools-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 }}
- name: Cache cargo build stage
id: cargo-cache
uses: actions/cache@v4
with:
path: |
~/.cargo
key: ${{ runner.os }}-android-cargo-${{ hashFiles('third_party/tun2proxy/Cargo.toml') }}-${{ hashFiles('third_party/tun2proxy/Cargo.lock') }}
- name: Cache golang
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-docker-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-docker-
- name: Gradle cache
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('android/**/*.gradle') }}
- name: Cache qemu-user-static
id: qemu-user-cache
uses: actions/cache@v4
with:
path: |
qemu-user-static*.deb
key: ${{ runner.os }}-qemu-8.2.5-ds-1
- name: Cache sysroot
id: sysroot-cache
uses: actions/cache@v4
with:
path: |
${{ env.SYSROOT }}
key: android-sysroot-${{ matrix.arch }}-v1
- name: Build build tool
run: |
cd tools
go build
- name: Replace Android NDK (to latest)
run: |
echo "ANDROID_NDK_ROOT=${ANDROID_NDK_LATEST_HOME}" >> $GITHUB_ENV
echo "ANDROID_NDK_HOME=${ANDROID_NDK_LATEST_HOME}" >> $GITHUB_ENV
- name: "Install dependency: tun2proxy"
run: |
./scripts/setup-android-rust.sh
WITH_OS=android WITH_CPU=${{ matrix.arch }} ./scripts/build-tun2proxy.sh
- name: "Install dependency: prebuilt clang and clang-tidy binaries"
if: ${{ steps.clang-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/download-clang-prebuilt-binaries.py
rm -f third_party/llvm-build/Release+Asserts/*.tgz
- name: Populate dependencie (cmake, overwrite)
run: |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.28.5/cmake-3.28.5-linux-x86_64.tar.gz
sudo tar -C /usr/local --strip-components=1 -xf cmake-3.28.5-linux-x86_64.tar.gz
cmake --version
rm -f *.tar.gz
- name: Build TGZ packages (no build, for patching)
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 \
-cmake-build-type MinSizeRel -no-build -no-configure \
-android-sdk-dir "${ANDROID_HOME}" -android-ndk-dir "${ANDROID_NDK_HOME}"
- name: Download and Build Crashpad (include depot_tools)
if: ${{ steps.depot-cache.outputs.cache-hit != 'true' || steps.crashpad-cache.outputs.cache-hit != 'true' }}
run: |
WITH_OS=android WITH_CPU=${{ matrix.arch }} ./scripts/build-crashpad.sh
- 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-static_8.2.5+ds-1_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 pkg-config gettext bubblewrap
# libc6-i386 interferes with x86 build
sudo apt remove libc6-i386
sudo apt install qemu-user
sudo apt remove -y qemu-user-binfmt
sudo dpkg -i qemu-user-static_*.deb
- 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 TGZ packages
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android --cmake-build-type MinSizeRel \
-build-benchmark -build-test \
-android-sdk-dir "${ANDROID_HOME}" -android-ndk-dir "${ANDROID_NDK_HOME}"
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
if [ ! -z $SIGNING_STORE_PATH ]; then
rm -f $SIGNING_STORE_PATH
fi
- 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: |
# required by leveldb unittests
mkdir -p $SYSROOT/data/local/tmp
qemu-${{ matrix.qemu_suffix }}-static -L $SYSROOT \
-E TMPDIR=$SYSROOT/data/local/tmp \
$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }}/yass_test
- 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