From ce98b2da42ccadd97e7e8833fda8b946da0ac4c7 Mon Sep 17 00:00:00 2001 From: dkk Date: Mon, 22 Jul 2024 18:45:39 +0800 Subject: [PATCH] Build APK action --- .github/workflows/build-apk.yml | 46 ++++++++++++++++++++ composeApp/android-proguard-rules.pro | 60 ++++++++++++++++++++++++++ composeApp/build.gradle.kts | 43 ++++++++++++++++++ signing/fubukidaze-android-debug | Bin 0 -> 2570 bytes 4 files changed, 149 insertions(+) create mode 100644 .github/workflows/build-apk.yml create mode 100644 composeApp/android-proguard-rules.pro create mode 100644 signing/fubukidaze-android-debug diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml new file mode 100644 index 0000000..d2558ef --- /dev/null +++ b/.github/workflows/build-apk.yml @@ -0,0 +1,46 @@ +name: BUILD APK + +on: + push: + branches: + - main + +jobs: + apk-build: + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + ANDROID_RELEASE_KEYSTORE_BASE64: ${{ secrets.ANDROID_RELEASE_KEYSTORE_BASE64 }} + ANDROID_RELEASE_KEYSTORE_PWD: ${{ secrets.ANDROID_RELEASE_KEYSTORE_PWD }} + ANDROID_RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_KEY_ALIAS }} + ANDROID_RELEASE_KEY_PWD: ${{ secrets.ANDROID_RELEASE_KEY_PWD }} + + steps: + - uses: actions/checkout@v3 + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Decode Keystore + run: | + echo $ANDROID_RELEASE_KEYSTORE_BASE64 > keystore_base64.txt + base64 -d keystore-b64.txt > fubukidaze-android-release + + - name: Assemble Release + run: | + ./gradlew :composeApp:assembleRelease + + - name: Get Release APK Path + id: releaseApk + run: echo "apkfile=$(find composeApp/build/outputs/apk/release/*.apk)" >> $GITHUB_OUTPUT + + - name: Upload APK to Artifacts + uses: actions/upload-artifact@v3 + with: + name: release-artifacts + path: ${{ steps.releaseApk.outputs.apkfile }} \ No newline at end of file diff --git a/composeApp/android-proguard-rules.pro b/composeApp/android-proguard-rules.pro new file mode 100644 index 0000000..3f6582e --- /dev/null +++ b/composeApp/android-proguard-rules.pro @@ -0,0 +1,60 @@ +# This is a configuration file for R8 + +#-verbose +#-allowaccessmodification +#-repackageclasses + +# Note that you cannot just include these flags in your own +# configuration file; if you are including this file, optimization +# will be turned off. You'll need to either edit this file, or +# duplicate the contents of this file and remove the include of this +# file from your project's proguard.config path property. + +# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native +-keepclasseswithmembernames class * { + native ; +} + +# We only need to keep ComposeView +-keep public class androidx.compose.ui.platform.ComposeView { + public (android.content.Context, android.util.AttributeSet); +} + +# For enumeration classes +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +# Kotlinx Serialization +-keep @kotlinx.serialization.Serializable class * {*;} + +# JNA +-dontwarn java.awt.* +-keep class com.sun.jna.** { *; } +-keep class * implements com.sun.jna.** { *; } +-keepclassmembers class * extends com.sun.jna.* { public *; } + + +# AndroidX + support library contains references to newer platform versions. +# Don't warn about those in case this app is linking against an older +# platform version. We know about them, and they are safe. +-dontwarn android.support.** +-dontwarn androidx.** + +#-keepattributes SourceFile, +# LineNumberTable, +# RuntimeVisibleAnnotations, +# RuntimeVisibleParameterAnnotations, +# RuntimeVisibleTypeAnnotations, +# AnnotationDefault + +-renamesourcefileattribute SourceFile + +# Using ktor client in Android has missing proguard rule +# See https://youtrack.jetbrains.com/issue/KTOR-5528 +-dontwarn org.slf4j.** diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 5ff322c..2b325a8 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -135,7 +135,50 @@ android { versionName = fubukidazeVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + ndk { + abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86_64") + } + } + + signingConfigs { + getByName("debug") { + storeFile = rootProject.file("signing/fubukidaze-android-debug") + storePassword = "android" + keyAlias = "androiddebugkey" + keyPassword = "android" + } + + create("release") { + if (rootProject.file("../fubukidaze-android-release").exists()) { + storeFile = rootProject.file("../fubukidaze-android-release") + storePassword = properties["ANDROID_RELEASE_KEYSTORE_PWD"]?.toString() ?: "" + keyAlias = properties["ANDROID_RELEASE_KEY_ALIAS"]?.toString() ?: "" + keyPassword = properties["ANDROID_RELEASE_KEY_PWD"]?.toString() ?: "" + } else { + storeFile = rootProject.file("signing/fubukidaze-android-debug") + storePassword = "android" + keyAlias = "androiddebugkey" + keyPassword = "android" + } + } } + + buildTypes { + debug { + signingConfig = signingConfigs["debug"] + versionNameSuffix = "-dev" + applicationIdSuffix = ".debug" + } + + release { + signingConfig = signingConfigs.findByName("release") ?: signingConfigs["debug"] + isShrinkResources = true + isMinifyEnabled = true + proguardFiles("android-proguard-rules.pro") + } + } + sourceSets["main"].apply { manifest.srcFile("src/androidMain/AndroidManifest.xml") res.srcDirs("src/androidMain/res") diff --git a/signing/fubukidaze-android-debug b/signing/fubukidaze-android-debug new file mode 100644 index 0000000000000000000000000000000000000000..73d79b9d30268686b802a8c8d9ec34a1354ed388 GIT binary patch literal 2570 zcma)8X*kr67M>YnGBMV%@8K3ozhPvT{g0?Dk$vC7ShFPCDA`i7?^||aFqSM~?8!Qj zElfg^o$Rjr-23!@?x%Y{oaa5~J?A~&&ifnydl?1+lL1(G6$~yEt{(my0loyz!NPN) zSa{|IoeE&d+y1LXj)P*!D=z4gizt9m{zpZ184St6k}F)0vVi>`1vvsR0wn(~sQ_Up zGVw-tzZR{BJmcQGa+Zb=KTG6XKLm1>76Rr0s9+TT-Uxw{g8)t#+%jApY)1wK3qfgz z>Q;5A-U<(7*3eY1>o842vCv@ywp7Ngd30x)pLZQ`weADdoQeXmJG`a*iK{jc?v?LO=d9Z@+8~#{59#=n@qF9P^T}wB)LeJm z_)c|Q<<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