-
Notifications
You must be signed in to change notification settings - Fork 199
/
.gitlab-ci.yml
114 lines (102 loc) · 4.9 KB
/
.gitlab-ci.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
variables:
ANDROID_COMPILE_SDK: "26"
ANDROID_BUILD_TOOLS: "26.0.2"
# the android sdk is too large to save as an artifact so we have to
# download and set it up for each job
.setup_android: &setup_android |
apt-get --quiet update -y
apt-get --quiet install -y curl unzip lib32stdc++6 lib32z1
curl -L -o android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
unzip -q android-sdk.zip -d android-sdk-linux
mkdir android-sdk-linux/licenses
yes | android-sdk-linux/tools/bin/sdkmanager --licenses || true
android-sdk-linux/tools/bin/sdkmanager --verbose "tools" "build-tools;$ANDROID_BUILD_TOOLS" "platform-tools" "platforms;android-$ANDROID_COMPILE_SDK" "extras;android;m2repository" "extras;google;m2repository"
export ANDROID_HOME=$PWD/android-sdk-linux
export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/:$PWD/android-sdk-linux/build-tools/$ANDROID_BUILD_TOOLS/
.setup_rust: &setup_rust |
apt-get update -q
apt-get install curl python unzip gcc -yq
curl -Lf https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init -o rustup-init.sh
chmod +x rustup-init.sh
./rustup-init.sh -y
source $HOME/.cargo/env
rustup target add armv7-linux-androideabi
rustup target add aarch64-linux-android
rustup target add i686-linux-android
rustup target add x86_64-linux-android
curl -L https://dl.google.com/android/repository/android-ndk-r17-linux-x86_64.zip -o android-ndk
unzip -q android-ndk
./android-ndk-r17/build/tools/make_standalone_toolchain.py --api 18 --install-dir=$ARMV7_TOOLCHAIN --arch=arm
./android-ndk-r17/build/tools/make_standalone_toolchain.py --api 21 --install-dir=$ARM64_TOOLCHAIN --arch=arm64
./android-ndk-r17/build/tools/make_standalone_toolchain.py --api 18 --install-dir=$x86_TOOLCHAIN --arch=x86
./android-ndk-r17/build/tools/make_standalone_toolchain.py --api 21 --install-dir=$x86_64_TOOLCHAIN --arch=x86_64
cd oab-utils
mkdir .cargo
printf "[target.armv7-linux-androideabi]\n linker = \""$(realpath ../$ARMV7_TOOLCHAIN)"/bin/arm-linux-androideabi-clang\"\n [target.aarch64-linux-android]\n linker = \""$(realpath ../$ARM64_TOOLCHAIN)"/bin/aarch64-linux-android-clang\"\n [target.i686-linux-android]\n linker = \""$(realpath ../$x86_TOOLCHAIN)"/bin/i686-linux-android-clang\"\n [target.x86_64-linux-android]\n linker = \""$(realpath ../$x86_64_TOOLCHAIN)"/bin/x86_64-linux-android-clang\"\n" > .cargo/config
cd ..
stages:
- test
- cargo:test:nightly
- cargo
- build
- sign
build:
image: openjdk:8-jdk
stage: build
variables:
ASSETS: "src/main/assets"
ARMV7_TOOLCHAIN: armv7_toolchain
ARM64_TOOLCHAIN: arm64_toolchain
x86_TOOLCHAIN: x86_toolchain
x86_64_TOOLCHAIN: x86_64_toolchain
script:
- *setup_android
- *setup_rust
- mkdir -p $ASSETS
- mkdir apks
- ./gradlew clean build
- find build/outputs/apk -name *.apk -exec cp -v {} apks \;
artifacts:
paths:
- apks
sign:
image: openjdk:8-jdk
stage: sign
dependencies:
- build
script:
- *setup_android
# put into variable with `cat $keystore | base64 -w 0 | xclip -in -selection clipboard`
- echo $ANDROID_KEY_BASE64 | base64 -d > android-release-key.jks
- zipalign -v -p 4 apks/oandbackup-arm-release-unsigned.apk oandbackup-unsigned-aligned-arm.apk
- apksigner sign --ks android-release-key.jks --ks-pass pass:$ANDROID_KEY_PASSWORD --out oandbackup-signed-arm.apk oandbackup-unsigned-aligned-arm.apk
- zipalign -v -p 4 apks/oandbackup-arm64-release-unsigned.apk oandbackup-unsigned-aligned-arm64.apk
- apksigner sign --ks android-release-key.jks --ks-pass pass:$ANDROID_KEY_PASSWORD --out oandbackup-signed-arm64.apk oandbackup-unsigned-aligned-arm64.apk
- zipalign -v -p 4 apks/oandbackup-x86-release-unsigned.apk oandbackup-unsigned-aligned-x86.apk
- apksigner sign --ks android-release-key.jks --ks-pass pass:$ANDROID_KEY_PASSWORD --out oandbackup-signed-x86.apk oandbackup-unsigned-aligned-x86.apk
- zipalign -v -p 4 apks/oandbackup-x86_64-release-unsigned.apk oandbackup-unsigned-aligned-x86_64.apk
- apksigner sign --ks android-release-key.jks --ks-pass pass:$ANDROID_KEY_PASSWORD --out oandbackup-signed-x86_64.apk oandbackup-unsigned-aligned-x86_64.apk
- zipalign -v -p 4 apks/oandbackup-universal-release-unsigned.apk oandbackup-unsigned-aligned-universal.apk
- apksigner sign --ks android-release-key.jks --ks-pass pass:$ANDROID_KEY_PASSWORD --out oandbackup-signed-universal.apk oandbackup-unsigned-aligned-universal.apk
artifacts:
paths:
- oandbackup-signed-arm.apk
- oandbackup-signed-arm64.apk
- oandbackup-signed-x86.apk
- oandbackup-signed-x86_64.apk
- oandbackup-signed-universal.apk
only:
- master
test:cargo:
image: rust:1.30-slim-stretch
stage: test
script:
- cd oab-utils
- cargo test
cargo:test:nightly:
image: rustlang/rust:nightly
stage: cargo:test:nightly
script:
- cd oab-utils
- cargo test
allow_failure: true