Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

test #18

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: pipeline
name: WireGuardX

clone:
depth: 1

steps:
- name: assembleDebug
image: archlinux:latest
environment:
TG_BOT_API:
from_secret: TG_BOT_API
commands:
- "export TG_BOT_API"
- pacman -Sy make git gradle zip unzip wget patch ninja curl jdk8-openjdk jre8-openjdk cmake glibc --noconfirm
- bash dronebuild
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: gradle # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
activityVersion = '1.2.0-alpha07'
activityVersion = '1.2.0-alpha08'
agpVersion = '4.0.1'
annotationsVersion = '1.1.0'
appcompatVersion = '1.2.0'
Expand Down
46 changes: 46 additions & 0 deletions dronebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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}

bash ${ANDROID_HOME}/cmdline-tools/tools/bin/sdkmanager --install "ndk;21.0.6113669"

DATE="`date +%d%m%Y-%H%M%S`"

HEAD_COMMIT="$(git rev-parse HEAD)"
GITHUB_URL="https://github.com/SensiPeeps/WireGuardX/commit/"
DRONE_URL="https://cloud.drone.io/SensiPeeps/WireGuardX/"

echo "sdk.dir=${ANDROID_HOME}" > local.properties

git clone https://github.com/WireGuard/wireguard-tools.git tunnel/tools/wireguard-tools/.

curl -s -X POST "https://api.telegram.org/bot${TG_BOT_API}/sendMessage" -d chat_id="-1001142276906" \
-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}) ⚒️"

./gradlew assembleDebug

if [ -f ui/build/outputs/apk/debug/ui-debug.apk ]; then
cp ui/build/outputs/apk/debug/ui-debug.apk ui/build/outputs/apk/debug/WireGuardX-debug-${DATE}.apk
cd ui/build/outputs/apk/debug
APK=$(echo WireGuardX-debug-*.apk)
curl -F document=@"${APK}" "https://api.telegram.org/bot${TG_BOT_API}/sendDocument" \
-F chat_id="-1001142276906" \
-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="-1001142276906" \
-d "disable_web_page_preview=true" \
-d "parse_mode=html" \
-d text="❌ <b>Build error, exiting now!</b>"
fi
53 changes: 53 additions & 0 deletions license_accepter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
# credits: thyrlian

check_android_home() {
if [ "$#" -lt 1 ]; then
if [ -z "${ANDROID_HOME}" ]; then
echo "Please either set ANDROID_HOME environment variable, or pass ANDROID_HOME directory as a parameter"
exit 1
else
ANDROID_HOME="${ANDROID_HOME}"
fi
else
ANDROID_HOME=$1
fi
echo "ANDROID_HOME is at $ANDROID_HOME"
}

accept_all_android_licenses() {
ANDROID_LICENSES="$ANDROID_HOME/licenses"
if [ ! -d $ANDROID_LICENSES ]; then
echo "Android licenses directory doesn't exist, creating one..."
mkdir -p $ANDROID_LICENSES
fi

accept_license_of android-googletv-license 601085b94cd77f0b54ff86406957099ebe79c4d6
accept_license_of android-sdk-license 8933bad161af4178b1185d1a37fbf41ea5269c55
accept_license_of android-sdk-license d56f5187479451eabf01fb78af6dfcb131a6481e
accept_license_of android-sdk-license 24333f8a63b6825ea9c5514f83c2829b004d1fee
accept_license_of android-sdk-preview-license 84831b9409646a918e30573bab4c9c91346d8abd
accept_license_of android-sdk-preview-license 504667f4c0de7af1a06de9f4b1727b84351f2910
accept_license_of google-gdk-license 33b6a2b64607f11b759f320ef9dff4ae5c47d97a
accept_license_of intel-android-extra-license d975f751698a77b662f1254ddbeed3901e976f5a
}

accept_license_of() {
local license=$1
local content=$2
local file=$ANDROID_LICENSES/$license
if [ -f $file ]; then
if grep -q "^$content$" $file; then
echo "$license: $content has been accepted already"
else
echo "Accepting $license: $content ..."
echo -e $content >> $file
fi
else
echo "Accepting $license: $content ..."
echo -e $content > $file
fi
}

check_android_home "$@"
accept_all_android_licenses