From 4611743ef358ada1aa27725d1d7f7b7aabf7ff39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 18 Feb 2021 10:32:07 +0800 Subject: [PATCH] Add debug workflow --- .github/workflows/debug.yml | 111 +++++++++++++++++++++++++++++++++++ .github/workflows/native.yml | 41 +++++++++++++ README.md | 2 + TMessagesProj/build.gradle | 21 ++++--- bin/init/action.sh | 10 ++++ bin/init/debian.sh | 20 ------- bin/libs/update.sh | 4 +- bin/libs/v2ray.sh | 37 ++++++------ build.gradle | 6 +- ss-rust/build.gradle.kts | 2 +- ssr-libev/build.gradle | 2 +- 11 files changed, 205 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/debug.yml create mode 100644 .github/workflows/native.yml create mode 100755 bin/init/action.sh delete mode 100755 bin/init/debian.sh diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 000000000..d93485fc4 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,111 @@ +name: Debug build + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + - '.github/**' + - '!.github/workflows/debug.yml' +jobs: + native: + name: Native Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + - name: Native Cache + uses: actions/cache@main + with: + path: | + TMessagesProj/libs + TMessagesProj/src/main/libs + key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} + - name: Check Cache + run: | + [ -f "TMessagesProj/libs/libv2ray.aar" ] && echo "Cache found." || echo "CONTINUE=true" >> $GITHUB_ENV + - name: Install NDK + if: env.CONTINUE + run: | + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - uses: actions/setup-go@v2 + if: env.CONTINUE + with: + go-version: ^1.15 + - name: Native Build + if: env.CONTINUE + run: | + ./run init action + ./run init libs + ./run libs update + debug: + name: Debug Build + runs-on: ubuntu-latest + needs: native + strategy: + matrix: + flavor: + - FullRelease + - FullReleaseNoGcm + - FullAppleEmojiRelease + - FullAppleEmojiReleaseNoGcm + - MiniRelease + - MiniReleaseNoGcm + - MiniAppleEmojiRelease + - MiniAppleEmojiReleaseNoGcm + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + - name: Native Cache + uses: actions/cache@main + with: + path: | + TMessagesProj/libs + TMessagesProj/src/main/libs + key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} + - name: Fix Gradle Memoery + run: | + sed -i -e "s/16384/6144/g" gradle.properties + echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties + - name: Gradle cache + uses: actions/cache@main + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle') }} + - name: Debug Build + run: | + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + export DEBUG_BUILD=true + ./gradlew TMessagesProj:assemble${{ matrix.flavor }} + + echo "APK_FILE=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk')" >> $GITHUB_ENV + echo "APK_FILE_ARMV7=$(find TMessagesProj/build/outputs/apk -name '*armeabi*.apk')" >> $GITHUB_ENV + echo "APK_FILE_X86=$(find TMessagesProj/build/outputs/apk -name '*x86-*.apk')" >> $GITHUB_ENV + echo "APK_FILE_X64=$(find TMessagesProj/build/outputs/apk -name '*x86_64*.apk')" >> $GITHUB_ENV + - uses: actions/upload-artifact@v2 + name: Upload apk (arm64-v8a) + with: + name: NekoX-${{ matrix.flavor }}-arm64-v8a + path: ${{ env.APK_FILE }} + - uses: actions/upload-artifact@v2 + name: Upload apk (armeabi-v7a) + with: + name: NekoX-${{ matrix.flavor }}-armeabi-v7a + path: ${{ env.APK_FILE_ARMV7 }} + - uses: actions/upload-artifact@v2 + name: Upload apk (x86_64) + with: + name: NekoX-${{ matrix.flavor }}-x86_64 + path: ${{ env.APK_FILE_X64 }} + - uses: actions/upload-artifact@v2 + name: Upload apk (x86) + with: + name: NekoX-${{ matrix.flavor }}-x86 + path: ${{ env.APK_FILE_X86 }} \ No newline at end of file diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml new file mode 100644 index 000000000..c116a5d5f --- /dev/null +++ b/.github/workflows/native.yml @@ -0,0 +1,41 @@ +name: Native build + +on: + push: + branches: + - dev + paths: + - 'TMessagesProj/jni/**' + - 'ss-rust/src/main/rust/**' +jobs: + native: + name: Native Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + - name: Install NDK + run: | + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - uses: actions/setup-go@v2 + with: + go-version: ^1.15 + - name: Native Cache + uses: actions/cache@main + with: + path: | + TMessagesProj/libs + TMessagesProj/src/main/libs + key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} + - name: Fix Gradle Memoery + run: sed -i -e "s/16384/6144/g" gradle.properties + - name: Native Build + run: | + test -f TMessagesProj/libs/libv2ray.aar && exit 0 + ./run init action + ./run init libs + ./run libs update \ No newline at end of file diff --git a/README.md b/README.md index 62ed52623..2ae58b27d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ NekoX is an **free and open source** third-party Telegram client, based on Telegram-FOSS with features added. +[![Continuous integration](https://github.com/NekoX-Dev/NekoX/workflows/Debug%20build/badge.svg?branch=main)](https://github.com/NekoX-Dev/NekoX/actions) + - [Google Play Store](https://play.google.com/store/apps/details?id=nekox.messenger) - [Update News Telegram](https://t.me/NekogramX) - [GitHub Feedback](https://github.com/NekoX-Dev/NekoX/issues) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 4917df13c..ab63ef324 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -1,7 +1,14 @@ +import cn.hutool.core.util.RuntimeUtil + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' def verName = "7.4.2-rc07" + +if (System.getenv("DEBUG_BUILD") == "true") { + verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1)") +} + def verCode = 188 def officialVer = "7.4.2" @@ -115,15 +122,13 @@ def alias = null def pwd = null Properties properties -if (project.rootProject.file('local.properties').exists()) { +def base64 = System.getenv("LOCAL_PROPERTIES") +if (base64 != null && !base64.isBlank()) { + properties = new Properties() + properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) +} else if (project.rootProject.file('local.properties').exists()) { properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) -} else { - def base64 = System.getenv("LOCAL_PROPERTIES") - if (base64 != null && !base64.isBlank()) { - properties = new Properties() - properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) - } } if (properties != null) { @@ -139,7 +144,7 @@ pwd = pwd ?: System.getenv("ALIAS_PASS") android { compileSdkVersion 30 buildToolsVersion '30.0.3' - ndkVersion '21.3.6528147' + ndkVersion rootProject.ext.ndkVersion defaultConfig.applicationId = "nekox.messenger" diff --git a/bin/init/action.sh b/bin/init/action.sh new file mode 100755 index 000000000..5f70c1a82 --- /dev/null +++ b/bin/init/action.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +sudo apt-get install bison gcc make curl ninja-build -y + +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y +echo "source \$HOME/.cargo/env" >>$HOME/.bashrc && source $HOME/.cargo/env + +git submodule update --init --recursive +cd ss-rust/src/main/rust/shadowsocks-rust +rustup target install armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android diff --git a/bin/init/debian.sh b/bin/init/debian.sh deleted file mode 100755 index 1f186ad7a..000000000 --- a/bin/init/debian.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -function sudodo() { - sudo $@ || $@ -} - -sudodo apt-get install bison gcc make curl ninja-build -y - -bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) -source $HOME/.gvm/scripts/gvm -gvm install go1.15.6 -B -gvm use go1.15.6 --default - -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y -echo "source \$HOME/.cargo/env" >> $HOME/.bashrc && source $HOME/.cargo/env - -git submodule update --init --recursive - -cd ss-rust/src/main/rust/shadowsocks-rust -rustup target install armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android \ No newline at end of file diff --git a/bin/libs/update.sh b/bin/libs/update.sh index f27db4e2a..585ed1ac3 100755 --- a/bin/libs/update.sh +++ b/bin/libs/update.sh @@ -1,6 +1,6 @@ #!/bin/bash +bin/libs/v2ray.sh || exit 1 bin/libs/ss.sh || exit 1 bin/libs/ssr.sh || exit 1 -bin/libs/v2ray.sh || exit 1 -bin/libs/native.sh || exit 1 \ No newline at end of file +bin/libs/native.sh || exit 1 diff --git a/bin/libs/v2ray.sh b/bin/libs/v2ray.sh index b31885f7c..f199208e8 100755 --- a/bin/libs/v2ray.sh +++ b/bin/libs/v2ray.sh @@ -3,25 +3,28 @@ V2RAY_CORE_VERSION="4.34.0" source "bin/init/env.sh" -v2rayCore="$(go env GOPATH)/src/v2ray.com/core" +#v2rayCore="$(go env GOPATH)/src/v2ray.com/core" +# +#if [ ! -f "$v2rayCore/go.mod" ]; then +# git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION" --depth 1 +#fi +# +#cd "$v2rayCore" +#git fetch origin "v$V2RAY_CORE_VERSION" +#git checkout -b master +#git reset "v$V2RAY_CORE_VERSION" --hard -if [ ! -d "$v2rayCore" ]; then - mkdir -p "$v2rayCore" - git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION" --depth 1 - cd "$v2rayCore" -else - cd "$v2rayCore" - git fetch origin "v$V2RAY_CORE_VERSION" && git reset "v$V2RAY_CORE_VERSION" --hard || git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION" --depth 1 -fi - -export PATH="$PATH/$(go env $GOPATH/bin)" -go mod download -x - -cd "$PROJECT/TMessagesProj/libs" +export GO111MOUDLE=on go get -v golang.org/x/mobile/cmd/... -go get -d github.com/2dust/AndroidLibV2rayLite +export PATH="$PATH:$(go env GOPATH)/bin" gomobile init -gomobile bind -v -ldflags='-s -w' github.com/2dust/AndroidLibV2rayLite || exit 1 +cd "$PROJECT/build" +[ -d "v2ray" ] || git clone https://github.com/2dust/AndroidLibV2rayLite v2ray +cd v2ray +git reset --hard && git clean -fdx +sed -i -e "s|go 1.14|go 1.15|g" go.mod +go mod download -x +gomobile bind -v -ldflags='-s -w' . || exit 1 -rm *-sources.jar \ No newline at end of file +/bin/cp -f libv2ray.aar "$PROJECT/TMessagesProj/libs" diff --git a/build.gradle b/build.gradle index d894752a9..99d7a4d62 100644 --- a/build.gradle +++ b/build.gradle @@ -13,16 +13,18 @@ buildscript { classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0' classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3' classpath 'com.github.triplet.gradle:play-publisher:3.0.0' + classpath 'cn.hutool:hutool-core:5.5.8' } } -/*static String detectNdkVersion() { +static String detectNdkVersion() { def version = "21.3.6528147" def androidHome = System.getenv("ANDROID_HOME") if (androidHome == null) return version + if (new File(androidHome, "ndk/$version").isDirectory()) return version def versionFile = new File(androidHome,"ndk-bundle/source.properties") @@ -40,7 +42,7 @@ ext { ndkVersion = detectNdkVersion() -}*/ +} allprojects { repositories { diff --git a/ss-rust/build.gradle.kts b/ss-rust/build.gradle.kts index 37c01d047..a6e0d3098 100644 --- a/ss-rust/build.gradle.kts +++ b/ss-rust/build.gradle.kts @@ -7,7 +7,7 @@ plugins { android { - ndkVersion = "21.3.6528147" + ndkVersion = rootProject.extra.get("ndkVersion").toString() compileSdkVersion(30) defaultConfig { diff --git a/ssr-libev/build.gradle b/ssr-libev/build.gradle index 8054838be..90f8e3912 100644 --- a/ssr-libev/build.gradle +++ b/ssr-libev/build.gradle @@ -5,7 +5,7 @@ plugins { android { compileSdkVersion 30 buildToolsVersion '30.0.3' - ndkVersion "21.3.6528147" + ndkVersion rootProject.ext.ndkVersion defaultConfig { minSdkVersion 16