forked from radcolor/TweaksKM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dronebuild
52 lines (42 loc) · 2.18 KB
/
dronebuild
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
#!/bin/bash
ANDROID_SDK_VERSION=6609375
ANDROID_HOME="/opt/android-sdk"
mkdir -p ${ANDROID_HOME}/cmdline-tools
wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip
unzip *tools*linux*.zip -d ${ANDROID_HOME}/cmdline-tools
rm *tools*linux*.zip
cp license_accepter.sh /opt/
chmod +x /opt/license_accepter.sh && /opt/license_accepter.sh ${ANDROID_HOME}
DATE="`date +%d%m%Y-%H%M%S`"
HEAD_COMMIT="$(git rev-parse HEAD)"
GITHUB_URL="https://github.com/theradcolor/TweaksKM/commit/"
DRONE_URL="https://cloud.drone.io/theradcolor/TweaksKM/"
echo "sdk.dir=${ANDROID_HOME}" > local.properties
curl -s -X POST "https://api.telegram.org/bot${TG_BOT_API}/sendMessage" -d chat_id="-1001365210159" \
-d "disable_web_page_preview=true" \
-d "parse_mode=markdownV2" \
-d text="⚒️ [*Building*](${DRONE_URL}${DRONE_BUILD_NUMBER}) with HEAD as [*$(echo $HEAD_COMMIT | cut -c1-8)*](${GITHUB_URL}${HEAD_COMMIT}) ⚒️"
git clone https://theradcolor:${GITHUB_TOKEN}@github.com/theradcolor/app-keystores -b master
mv app-keystores/theradcolor.jks .
mv app-keystores/theradcolor_keystore.properties keystore.properties
export JOBS="$((`grep -c '^processor' /proc/cpuinfo`))"
echo "org.gradle.daemon=true" >> local.properties
echo "org.gradle.parallel=true" >> local.properties
echo "org.gradle.workers.max=${JOBS}" >> local.properties
./gradlew assembleRelease --parallel --max-workers=${JOBS}
if [ -f app/build/outputs/apk/release/app-release.apk ]; then
cp app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/TweaksKM-${DATE}.apk
cd app/build/outputs/apk/release/
APK=$(echo TweaksKM-*.apk)
curl --progress-bar -F document=@"${APK}" "https://api.telegram.org/bot${TG_BOT_API}/sendDocument" \
-F chat_id="-1001365210159" \
-F "disable_web_page_preview=true" \
-F "parse_mode=html" \
-F caption="⭕️ <b>CI build completed successfully!</b>"
rm -rf app/build/outputs/apk
else
curl -s -X POST "https://api.telegram.org/bot${TG_BOT_API}/sendMessage" -d chat_id="-1001365210159" \
-d "disable_web_page_preview=true" \
-d "parse_mode=html" \
-d text="❌ <b>Build error, exiting now!</b>"
fi