diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index 8405c4849..fb3636c1e 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -29,7 +29,14 @@ jobs: with: distribution: 'zulu' java-version: ${{ env.JAVA_VERSION }} - + - name: Create google-services.json + env: + GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }} + run: | + mkdir -p composeApp/ + mkdir -p composeApp/src/debug/ + echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > composeApp/google-services.json + cp composeApp/google-services.json composeApp/src/debug/google-services.json - name: Build Android App run: ./gradlew :composeApp:assembleDebug diff --git a/.github/workflows/cd-firebase.yml b/.github/workflows/cd-firebase.yml new file mode 100644 index 000000000..485a5af72 --- /dev/null +++ b/.github/workflows/cd-firebase.yml @@ -0,0 +1,84 @@ +name: EvolveFit CD Pipeline +on: + push: + branches: + - main + - develop + - feature/cd-firebase + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle-${{ runner.os }}- + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Create google-services.json + env: + GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }} + run: | + mkdir -p composeApp/ + echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > composeApp/google-services.json + echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > composeApp/google-services.json + shell: bash + + - name: Decode Keystore and Create local.properties + env: + KEYSTORE: ${{ secrets.KEYSTORE }} + KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} + KEY_ALIAS: ${{ secrets.KEY_ALIAS }} + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + run: | + rm -f composeApp/JKS.jks local.properties release_notes.txt + echo "$KEYSTORE" | base64 -d > composeApp/JKS.jks + echo "KEYSTORE_PASSWORD = $KEYSTORE_PASSWORD" >> local.properties + echo "KEY_ALIAS = $KEY_ALIAS" >> local.properties + echo "KEY_PASSWORD = $KEY_PASSWORD" >> local.properties + + - name: Generate Signed APK + run: | + ./gradlew assembleRelease --build-cache -x test -x lint + + - name: Find APKs + run: | + echo "Searching for APKs..." + find . -type f -name "*.apk" + + - name: Create Release Notes + run: | + echo "Automated build from GitHub Actions on $(date)" > release_notes.txt + + - name: Upload APKs to Firebase App Distribution + env: + FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} + FIREBASE_AUTH_TOKEN: ${{ secrets.FIREBASE_AUTH_TOKEN }} + run: | + npm install -g firebase-tools + firebase appdistribution:distribute \ + composeApp/build/outputs/apk/release/composeApp-release.apk \ + --app "$FIREBASE_APP_ID" \ + --token "$FIREBASE_AUTH_TOKEN" \ + --groups "cairo_squad" \ + --release-notes-file release_notes.txt \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index bca0fd741..42edf75c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,8 @@ plugins { alias(libs.plugins.composeMultiplatform) apply false alias(libs.plugins.composeCompiler) apply false alias(libs.plugins.kotlinMultiplatform) apply false + alias(libs.plugins.googleFirebaseAppdistribution) apply false + alias(libs.plugins.googleGmsGoogleServices) apply false } repositories { diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 79b50f8c6..3ba4a771f 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.io.FileInputStream import java.util.Properties +import kotlin.apply plugins { alias(libs.plugins.kotlinMultiplatform) @@ -9,6 +10,8 @@ plugins { alias(libs.plugins.composeMultiplatform) alias(libs.plugins.composeCompiler) kotlin("plugin.serialization") version libs.versions.kotlin + alias(libs.plugins.googleFirebaseAppdistribution) + alias(libs.plugins.googleGmsGoogleServices) alias(libs.plugins.ksp) alias(libs.plugins.androidx.room) } @@ -108,27 +111,28 @@ android { lint { disable += "NullSafeMutableLiveData" } + defaultConfig { + applicationId = "com.cairosquad.evolvefit" + minSdk = libs.versions.android.minSdk.get().toInt() + targetSdk = libs.versions.android.targetSdk.get().toInt() + versionCode = 1 + versionName = "1.0" + } val localFile = file("${rootProject.projectDir}/local.properties") val locals = Properties().apply { if (localFile.exists()) { load(FileInputStream(localFile)) } } + signingConfigs { create("release") { - storeFile = file("evolve-key.jks") + storeFile = file("JKS.jks") storePassword = locals.getProperty("KEYSTORE_PASSWORD") keyAlias = locals.getProperty("KEY_ALIAS") keyPassword = locals.getProperty("KEY_PASSWORD") } } - defaultConfig { - applicationId = "com.cairosquad.evolvefit" - minSdk = libs.versions.android.minSdk.get().toInt() - targetSdk = libs.versions.android.targetSdk.get().toInt() - versionCode = 1 - versionName = "1.0" - } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" @@ -136,10 +140,21 @@ android { } buildTypes { getByName("release") { - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = true signingConfig = signingConfigs.getByName("release") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) } } +// buildTypes { +// getByName("release") { +// isMinifyEnabled = false +// signingConfig = signingConfigs.getByName("release") +// } +// } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 048a27646..f715bda52 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,6 +25,8 @@ lifecycleViewModel = "2.9.1" filekit = "0.10.0" ktor = "3.2.3" core-splashscreen = "1.0.1" +googleFirebaseAppdistribution = "5.1.1" +googleGmsGoogleServices = "4.4.3" room = "2.7.2" sqlite = "2.5.2" ksp = "2.2.0-2.0.2" @@ -89,6 +91,9 @@ composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "k kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } androidx-room = { id = "androidx.room", version.ref = "room" } +googleFirebaseAppdistribution = { id = "com.google.firebase.appdistribution", version.ref = "googleFirebaseAppdistribution" } +googleGmsGoogleServices = { id = "com.google.gms.google-services", version.ref = "googleGmsGoogleServices" } + [bundles] ktor = [ "ktor-client-core",