From 197465924f31a71733db8719f4413560f803f56a Mon Sep 17 00:00:00 2001 From: Benjamin Halko Date: Tue, 23 Jan 2024 11:51:35 -0800 Subject: [PATCH] Updated build --- .github/workflows/pr-build.yml | 12 ++------- app/build.gradle.kts | 48 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index e4a04351f1..e75dd976f4 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -27,18 +27,10 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Build with Gradle - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew assembleRelease --no-daemon -PnoProguard -PsignAsDebug - - - name: Set env - run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - - name: Add hash to APK - run: mv app/build/outputs/apk/release/app-release.apk revanced-manager-${{ env.COMMIT_HASH }}.apk + run: ./gradlew assembleRelease --no-daemon -PnoProguard - name: Upload build uses: actions/upload-artifact@v3 with: name: revanced-manager - path: revanced-manager-${{ env.COMMIT_HASH }}.apk + path: app/build/outputs/apk/release/*.apk diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a4dc5f6a82..cf7a58ce28 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,18 +25,6 @@ android { vectorDrawables.useSupportLibrary = true } - val hasReleaseConfig = (System.getenv("KEYSTORE_FILE") != null) - signingConfigs { - if (hasReleaseConfig) { - create("release") { - storeFile = file(System.getenv("KEYSTORE_FILE")) - storePassword = System.getenv("KEYSTORE_PASSWORD") - keyAlias = System.getenv("KEY_ALIAS") - keyPassword = System.getenv("KEY_PASSWORD") - } - } - } - buildTypes { debug { applicationIdSuffix = ".debug" @@ -44,27 +32,39 @@ android { } release { + val hasReleaseConfig = (System.getenv("KEYSTORE_FILE") != null) + var suffix = "v${project.version}" + if (hasReleaseConfig) { + signingConfigs { + create("release") { + storeFile = file(System.getenv("KEYSTORE_FILE")) + storePassword = System.getenv("KEYSTORE_PASSWORD") + keyAlias = System.getenv("KEY_ALIAS") + keyPassword = System.getenv("KEY_PASSWORD") + } + } + signingConfig = signingConfigs.getByName("release") + } else { + applicationIdSuffix = ".debug" + resValue("string", "app_name", "ReVanced Manager Debug") + signingConfig = signingConfigs.getByName("debug") + val os = org.apache.commons.io.output.ByteArrayOutputStream() + project.exec { + commandLine = "git rev-parse --short HEAD".split(" ") + standardOutput = os + } + suffix = String(os.toByteArray()).trim() + } if (!project.hasProperty("noProguard")) { isMinifyEnabled = true isShrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } - if (!hasReleaseConfig) { - applicationIdSuffix = ".debug" - resValue("string", "app_name", "ReVanced Manager Debug") - signingConfig = signingConfigs.getByName("debug") - } else { - signingConfig = signingConfigs.getByName("release") - } applicationVariants.all { this.outputs .map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl } .forEach { output -> - if (applicationIdSuffix == ".debug") { - output.outputFileName = "revanced-manager-v${project.version}-debug.apk" - } else { - output.outputFileName = "revanced-manager-v${project.version}.apk" - } + output.outputFileName = "revanced-manager-${suffix}.apk" } } }