From 7055cfa262de97a90d29fa6945460b3a1b365a37 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 30 Oct 2022 18:50:44 +0800 Subject: [PATCH] Bump to 4.1 --- .github/workflows/android.yml | 32 +++++------ app/build.gradle | 47 ---------------- app/build.gradle.kts | 94 ++++++++++++++++++++++++++++++++ build.gradle => build.gradle.kts | 4 +- gradle.properties | 6 +- settings.gradle | 1 - settings.gradle.kts | 1 + 7 files changed, 117 insertions(+), 68 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts rename build.gradle => build.gradle.kts (72%) delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a81b7dd..6fe3ad7 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -15,31 +15,29 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' cache: 'gradle' - - name: Build with Gradle - run: ./gradlew assembleRelease - - - name: Sign app APK + - name: Write key if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - uses: r0adkll/sign-android-release@v1 - # ID used to access action output - id: sign_app - with: - releaseDirectory: app/build/outputs/apk/release - signingKeyBase64: ${{ secrets.SIGNING_KEY }} - alias: ${{ secrets.ALIAS }} - keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} - keyPassword: ${{ secrets.KEY_PASSWORD }} + run: | + if [ ! -z "${{ secrets.KEY_STORE }}" ]; then + echo releaseStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties + echo releaseKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties + echo releaseKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties + echo releaseStoreFile='key.jks' >> gradle.properties + echo ${{ secrets.SIGNING_KEY }} | base64 --decode > key.jks + fi + + - name: Build with Gradle + run: ./gradlew assembleRelease assembleDebug - name: Upload artifact - if: steps.sign_app.outcome == 'success' uses: actions/upload-artifact@v3 with: name: Signed app bundle - path: ${{steps.sign_app.outputs.signedReleaseFile}} + path: app/build/outputs/apk diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index c60a335..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 33 - buildToolsVersion '32.0.0' - defaultConfig { - applicationId "com.coderstory.toolkit" - minSdkVersion 29 - targetSdkVersion 33 - versionCode 1984 - versionName "4.0" - } - - signingConfigs { - release { - } - } - packagingOptions { - jniLibs { - excludes += ['META-INF/**'] - } - resources { - excludes += ['META-INF/**'] - } - } - - - buildTypes { - release { - minifyEnabled true - shrinkResources true - proguardFiles 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - lint { - abortOnError false - } - namespace 'com.coderstory.toolkit' -} - -dependencies { - compileOnly 'de.robv.android.xposed:api:82' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..0f484e5 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,94 @@ +import java.nio.file.Paths + +plugins { + id("com.android.application") +} + +val releaseStoreFile: String? by rootProject +val releaseStorePassword: String? by rootProject +val releaseKeyAlias: String? by rootProject +val releaseKeyPassword: String? by rootProject + +android { + compileSdk = 33 + buildToolsVersion = "33.0.0" + defaultConfig { + applicationId = "com.coderstory.toolkit" + minSdk = 29 + targetSdk = 33 + versionCode = 1989 + versionName = "4.1" + } + + signingConfigs { + create("config") { + releaseStoreFile?.also { + storeFile = rootProject.file(it) + storePassword = releaseStorePassword + keyAlias = releaseKeyAlias + keyPassword = releaseKeyPassword + } + } + } + packagingOptions { + jniLibs { + excludes += "META-INF/**" + } + resources { + excludes += "META-INF/**" + } + } + + + buildTypes { + all { + signingConfig = + if (releaseStoreFile.isNullOrEmpty()) signingConfigs.getByName("debug") else signingConfigs.getByName( + "config" + ) + } + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles("proguard-rules.pro") + } + } + compileOptions { + sourceCompatibility(JavaVersion.VERSION_11) + targetCompatibility(JavaVersion.VERSION_11) + } + lint { + abortOnError = false + } + namespace = "com.coderstory.toolkit" +} + +dependencies { + compileOnly("de.robv.android.xposed:api:82") +} +val optimizeReleaseRes = task("optimizeReleaseRes").doLast { + val aapt2 = Paths.get( + project.android.sdkDirectory.path, + "build-tools", project.android.buildToolsVersion, "aapt2" + ) + val zip = Paths.get( + project.buildDir.path, "intermediates", + "optimized_processed_res", "release", "resources-release-optimize.ap_" + ) + val optimized = File("${zip}.opt") + val cmd = exec { + commandLine(aapt2, "optimize", "--collapse-resource-names", "-o", optimized, zip) + isIgnoreExitValue = true + } + if (cmd.exitValue == 0) { + delete(zip) + optimized.renameTo(zip.toFile()) + } +} +tasks.whenTaskAdded { + when (name) { + "optimizeReleaseResources" -> { + finalizedBy(optimizeReleaseRes) + } + } +} diff --git a/build.gradle b/build.gradle.kts similarity index 72% rename from build.gradle rename to build.gradle.kts index e89865e..ef1f842 100644 --- a/build.gradle +++ b/build.gradle.kts @@ -6,7 +6,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' + classpath("com.android.tools.build:gradle:7.3.1") } } @@ -14,7 +14,7 @@ allprojects { repositories { google() mavenCentral() - maven { url "https://jcenter.bintray.com" } + maven(url = "https://jcenter.bintray.com") } } diff --git a/gradle.properties b/gradle.properties index ad345bf..d89d7fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,4 +14,8 @@ # org.gradle.parallel=true #Fri Nov 17 23:21:15 CST 2017 android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +android.nonTransitiveRClass=true +android.enableAppCompileTimeRClass=true +android.enableR8.fullMode=true +android.experimental.enableNewResourceShrinker=true +android.experimental.enableNewResourceShrinker.preciseShrinking=true diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..15a801b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +include(":app")