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 0000000..73d79b9 Binary files /dev/null and b/signing/fubukidaze-android-debug differ