add keep awake controller #106
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build APK | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| required: false | |
| type: string | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| fetch-depth: '0' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v4 | |
| with: | |
| log-accepted-android-sdk-licenses: false | |
| cmdline-tools-version: '14742923' | |
| packages: 'platforms;android-37.0 build-tools;37.0.0 platform-tools' | |
| - name: Install NDK | |
| run: | | |
| echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \ | |
| --channel=0 \ | |
| --install "ndk;29.0.14206865" | |
| echo "NDK_HOME=$ANDROID_HOME/ndk/29.0.14206865" >> $GITHUB_ENV | |
| sed -i '10i\ | |
| \ | |
| ndkVersion = "29.0.14206865"' ${{ github.workspace }}/V2rayNG/app/build.gradle.kts | |
| - name: Restore cached libhevtun | |
| id: cache-libhevtun-restore | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: ${{ github.workspace }}/libs | |
| key: libhevtun-${{ runner.os }}-${{ env.NDK_HOME }}-${{ hashFiles('.git/modules/hev-socks5-tunnel/HEAD') }}-${{ hashFiles('compile-hevtun.sh') }} | |
| - name: Build libhevtun | |
| if: steps.cache-libhevtun-restore.outputs.cache-hit != 'true' | |
| run: | | |
| bash compile-hevtun.sh | |
| - name: Save libhevtun | |
| if: steps.cache-libhevtun-restore.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: ${{ github.workspace }}/libs | |
| key: libhevtun-${{ runner.os }}-${{ env.NDK_HOME }}-${{ hashFiles('.git/modules/hev-socks5-tunnel/HEAD') }}-${{ hashFiles('compile-hevtun.sh') }} | |
| - name: Copy libhevtun | |
| run: | | |
| cp -r ${{ github.workspace }}/libs ${{ github.workspace }}/V2rayNG/app | |
| - name: Fetch AndroidLibXrayLite tag | |
| run: | | |
| pushd AndroidLibXrayLite | |
| CURRENT_TAG=$(git describe --tags --abbrev=0) | |
| echo "Current tag in this repo: $CURRENT_TAG" | |
| echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_ENV | |
| popd | |
| - name: Download libv2ray | |
| uses: robinraju/release-downloader@v1.13 | |
| with: | |
| repository: '2dust/AndroidLibXrayLite' | |
| tag: ${{ env.CURRENT_TAG }} | |
| fileName: 'libv2ray.aar' | |
| out-file-path: V2rayNG/app/libs/ | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Decode Keystore | |
| uses: timheuer/base64-to-file@v2.0.0 | |
| id: android_keystore | |
| with: | |
| fileName: "android_keystore.jks" | |
| encodedString: ${{ secrets.APP_KEYSTORE_BASE64 }} | |
| - name: Build APK | |
| run: | | |
| cd ${{ github.workspace }}/V2rayNG | |
| echo "sdk.dir=${ANDROID_HOME}" > local.properties | |
| chmod 755 gradlew | |
| ./gradlew licenseReleaseReport | |
| ./gradlew assembleRelease -Pandroid.injected.signing.store.file=${{ steps.android_keystore.outputs.filePath }} -Pandroid.injected.signing.store.password=${{ secrets.APP_KEYSTORE_PASSWORD }} -Pandroid.injected.signing.key.alias=${{ secrets.APP_KEYSTORE_ALIAS }} -Pandroid.injected.signing.key.password=${{ secrets.APP_KEY_PASSWORD }} | |
| - name: Sign APKs with v1, v2, and v3 | |
| run: | | |
| BUILD_TOOLS_DIR="$ANDROID_HOME/build-tools/36.1.0" | |
| for apk in ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/release/*.apk; do | |
| if [ -f "$apk" ]; then | |
| echo "Signing $apk with v1, v2, and v3 schemes..." | |
| $BUILD_TOOLS_DIR/apksigner sign \ | |
| --ks ${{ steps.android_keystore.outputs.filePath }} \ | |
| --ks-pass pass:${{ secrets.APP_KEYSTORE_PASSWORD }} \ | |
| --ks-key-alias ${{ secrets.APP_KEYSTORE_ALIAS }} \ | |
| --key-pass pass:${{ secrets.APP_KEY_PASSWORD }} \ | |
| --v1-signing-enabled true \ | |
| --v2-signing-enabled true \ | |
| --v3-signing-enabled true \ | |
| "$apk" | |
| echo "Verifying signatures for $apk..." | |
| $BUILD_TOOLS_DIR/apksigner verify -v "$apk" | |
| fi | |
| done | |
| - name: Upload arm64-v8a APK | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ success() }} | |
| with: | |
| name: arm64-v8a | |
| path: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/release/*arm64-v8a*.apk | |
| - name: Upload armeabi-v7a APK | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ success() }} | |
| with: | |
| name: armeabi-v7a | |
| path: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/release/*armeabi-v7a*.apk | |
| - name: Upload x86 APK | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ success() }} | |
| with: | |
| name: x86-apk | |
| path: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/release/*x86*.apk | |
| - name: Upload to release | |
| uses: svenstaro/upload-release-action@v2 | |
| if: github.event.inputs.release_tag != '' | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/release/*.apk | |
| tag: ${{ github.event.inputs.release_tag }} | |
| file_glob: true | |
| prerelease: true |