diff --git a/.github/workflows/master.yml b/.github/workflows/build.yml similarity index 63% rename from .github/workflows/master.yml rename to .github/workflows/build.yml index 72224da..3d8c0df 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/build.yml @@ -1,27 +1,30 @@ -name: Build CI +name: CI Build on: workflow_dispatch: pull_request: + push: merge_group: jobs: build: - runs-on: macos-latest + name: Build + runs-on: ubuntu-latest env: CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion' CCACHE_NOHASHDIR: 'true' CCACHE_HARDLINK: 'true' - CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_BASEDIR: '${{ github.workspace }}' steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: - submodules: recursive + ref: ${{ github.sha }} + submodules: 'recursive' fetch-depth: 0 - - name: Cache Gradle + - name: Cache CCACHE uses: actions/cache@v4 with: path: | @@ -37,15 +40,17 @@ jobs: path: ~/.m2/repository key: ${{ runner.os }}-m2-${{ hashFiles('**/build.gradle*') }} restore-keys: | - ${{ runner.os }}-m2- + ${{ runner.os }}-ccache- - - name: Cache ccache + - name: Cache Android Build Cache uses: actions/cache@v4 with: - path: ~/.ccache - key: ${{ runner.os }}-ccache-${{ hashFiles('**/src/**/*.cpp', '**/src/**/*.h', '**/CMakeLists.txt') }} + path: | + ~/.android/build-cache + ~/.gradle/caches/modules-2 + key: ${{ runner.os }}-android-build-cache-${{ hashFiles('**/build.gradle*', '**/*.versions.toml') }} restore-keys: | - ${{ runner.os }}-ccache- + ${{ runner.os }}-android-build-cache- - name: Write signing key if needed if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' @@ -72,13 +77,13 @@ jobs: path: libxposed/service - name: Setup Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: java-version: '21' distribution: 'adopt' - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@v5 - name: Setup Android SDK uses: android-actions/setup-android@v3 @@ -89,43 +94,53 @@ jobs: version: 1.12.0 - name: Remove Android's cmake - run: rm -rf $ANDROID_HOME/cmake + shell: bash + run: rm -rf "$ANDROID_HOME/cmake" - - name: Build local dependencies + - name: Setup build environment properties run: | - echo "--- Building API dependency ---" - cd libxposed/api - ./gradlew :api:publishApiPublicationToMavenLocal --no-daemon - echo "--- Building Service Interface dependency ---" + # for libxposed/api build + echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/api/gradle.properties + + # for main project build + { + echo 'org.gradle.parallel=true' + echo 'org.gradle.jvmargs=-Xmx2048m' + echo 'android.native.buildOutput=verbose' + } >> gradle.properties + + - name: Build dependencies with Gradle + working-directory: libxposed + run: | + cd api + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + ./gradlew :api:publishApiPublicationToMavenLocal cd ../service - ./gradlew :interface:publishInterfacePublicationToMavenLocal --no-daemon + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + ./gradlew :interface:publishInterfacePublicationToMavenLocal - name: Set short commit id - run: echo "commit=$(echo ${{ github.sha }} | cut -c-7)" >> $GITHUB_ENV + run: echo "commit=$(echo ${{ github.sha }} | cut -c-7)" > $GITHUB_ENV - name: Build with Gradle - run: | - echo 'org.gradle.parallel=true' >> gradle.properties - echo 'org.gradle.jvmargs=-Xmx3g' >> gradle.properties - echo 'android.native.buildOutput=verbose' >> gradle.properties - ./gradlew buildAll - - - name: Upload Debug artifact - uses: actions/upload-artifact@v4 - with: - name: npatch-debug - path: out/debug/* + run: ./gradlew buildAll - name: Upload Release artifact uses: actions/upload-artifact@v4 with: - name: npatch-release + name: npatch-release-${{ env.commit }} path: out/release/* + - name: Upload Debug artifact + uses: actions/upload-artifact@v4 + with: + name: npatch-debug-${{ env.commit }} + path: out/debug/* + - name: Upload mappings uses: actions/upload-artifact@v4 with: - name: mappings + name: mappings-${{ env.commit }} path: | patch-loader/build/outputs/mapping manager/build/outputs/mapping @@ -133,6 +148,6 @@ jobs: - name: Upload symbols uses: actions/upload-artifact@v4 with: - name: symbols + name: symbols-${{ env.commit }} path: | - patch-loader/build/symbols \ No newline at end of file + patch-loader/build/symbols diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml index 217d80a..6dabad2 100644 --- a/.github/workflows/clean.yml +++ b/.github/workflows/clean.yml @@ -1,4 +1,4 @@ -name: Clean Gradle Cache +name: Clean Build on: workflow_dispatch: @@ -14,4 +14,18 @@ jobs: run: rm -rf ~/.m2/repository/ - name: 删除 ccache 缓存 - run: rm -rf ~/.ccache/ \ No newline at end of file + run: rm -rf ~/.ccache/ + + cleanup-runs: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: 清理所有失敗的 Workflows + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + retain_days: 0 + keep_minimum_runs: 1 + delete_run_by_conclusion_pattern: 'failure,skipped' \ No newline at end of file