feat: add foreground service to keep-alive #33
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 Signed APK | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Make gradlew executable | |
| run: chmod +x gradlew | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: nightly-2026-01-21 | |
| targets: "x86_64-unknown-linux-gnu" | |
| components: "rustfmt,clippy,rust-src" | |
| - name: Install Android NDK | |
| uses: nttld/setup-ndk@v1 | |
| with: | |
| ndk-version: r27d | |
| add-to-path: true | |
| - name: Add Rust Android targets | |
| run: | | |
| rustup target add aarch64-linux-android | |
| rustup target add armv7-linux-androideabi | |
| rustup target add i686-linux-android | |
| rustup target add x86_64-linux-android | |
| - name: Install Protoc | |
| uses: arduino/setup-protoc@v3 | |
| with: | |
| version: "23.x" | |
| - uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-ndk | |
| - name: Cache Gradle dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| uniffi/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Decode Keystore | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: | | |
| echo "$KEYSTORE_BASE64" | base64 --decode > keystore.jks | |
| - name: Get version info | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=dev-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Gen binding | |
| run: | | |
| touch local.properties | |
| ./gradlew assembleDebug -Prust-target=arm64 | |
| ./gradlew clean | |
| cd uniffi | |
| cargo clean | |
| - name: Build all APKs | |
| env: | |
| KEYSTORE_FILE: ${{ github.workspace }}/keystore.jks | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| ANDROID_SPLIT_ABI_ENABLE: true | |
| ANDROID_SPLIT_ABI_UNIVERSAL_APK: true | |
| run: | | |
| ./gradlew assembleRelease | |
| - name: Organize APKs | |
| run: | | |
| mkdir -p output | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Copy and rename APKs | |
| cp app/build/outputs/apk/release/*-arm64-v8a-release.apk output/clash-android-${VERSION}-arm64-v8a.apk || true | |
| cp app/build/outputs/apk/release/*-armeabi-v7a-release.apk output/clash-android-${VERSION}-armeabi-v7a.apk || true | |
| cp app/build/outputs/apk/release/*-x86-release.apk output/clash-android-${VERSION}-x86.apk || true | |
| cp app/build/outputs/apk/release/*-x86_64-release.apk output/clash-android-${VERSION}-x86_64.apk || true | |
| cp app/build/outputs/apk/release/*-universal-release.apk output/clash-android-${VERSION}-all.apk || true | |
| ls -lh output/ | |
| - name: Upload APK artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: apk-all-platforms | |
| path: output/*.apk | |
| retention-days: 30 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || 'latest' }} | |
| name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || 'Latest' }} | |
| files: output/*.apk | |
| draft: false | |
| prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |