Skip to content

Commit

Permalink
Build APK action
Browse files Browse the repository at this point in the history
  • Loading branch information
darkokoa committed Jul 22, 2024
1 parent 586cda4 commit 197463e
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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@v4

- name: Setup JDK
uses: actions/setup-java@v4
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@v4
with:
name: release-artifacts
path: ${{ steps.releaseApk.outputs.apkfile }}
60 changes: 60 additions & 0 deletions composeApp/android-proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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 <methods>;
}

# We only need to keep ComposeView
-keep public class androidx.compose.ui.platform.ComposeView {
public <init>(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.**
43 changes: 43 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Binary file added signing/fubukidaze-android-debug
Binary file not shown.

0 comments on commit 197463e

Please sign in to comment.