Skip to content

Commit

Permalink
Merge pull request #48 from nimblehq/feature/6-set-up-cd-android
Browse files Browse the repository at this point in the history
[#6] [Android] Set up CD workflow
  • Loading branch information
luongvo authored Dec 1, 2023
2 parents 71cbe98 + 3309052 commit 9f3c513
Show file tree
Hide file tree
Showing 82 changed files with 587 additions and 367 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy production app to Firebase App Distribution
on:
push:
branches:
- main

jobs:
deploy_android:
name: Deploy Android app to Firebase App Distribution
runs-on: ubuntu-latest
timeout-minutes: 30
environment: production
defaults:
run:
working-directory: ./sample
steps:
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'

- name: Checkout source code
uses: actions/checkout@v3

- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches/modules-*
~/.gradle/caches/jars-*
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up the necessary config
run: |
echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties
echo "${{ secrets.ANDROID_SIGNING_PROPERTIES }}" > signing.properties
echo "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" | base64 --decode > config/release.keystore
- name: Build production APK
run: ./gradlew assembleProductionRelease -PversionCode=$GITHUB_RUN_NUMBER

- name: Deploy production to Firebase
uses: wzieba/[email protected]
with:
appId: ${{ vars.ANDROID_FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
groups: nimble
file: sample/android/build/outputs/apk/production/release/android-production-release.apk
49 changes: 49 additions & 0 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy staging app to Firebase App Distribution
on:
push:
branches:
- develop

jobs:
deploy_android:
name: Deploy Android app to Firebase App Distribution
runs-on: ubuntu-latest
timeout-minutes: 30
environment: staging
defaults:
run:
working-directory: ./sample
steps:
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'

- name: Checkout source code
uses: actions/checkout@v3

- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches/modules-*
~/.gradle/caches/jars-*
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up the necessary config
run: echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties

- name: Build staging APK
run: ./gradlew assembleStagingDebug -PversionCode=$GITHUB_RUN_NUMBER

- name: Deploy staging to Firebase
uses: wzieba/[email protected]
with:
appId: ${{ vars.ANDROID_FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
groups: nimble
file: sample/android/build/outputs/apk/staging/debug/android-staging-debug.apk
17 changes: 11 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Code analysis, test and generate sample project
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
types: [ opened, edited, reopened, synchronize ]
push:
branches-ignore:
- main
- develop
- 'release/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -47,7 +52,7 @@ jobs:
run: rm -rf sample

- name: Generate the new sample project
run: ./make.sh --bundle-id co.nimblehq.kmm.sample --bundle-id-staging co.nimblehq.kmm.sample.staging --project-name sample --ios-version 14.0
run: ./make.sh --bundle-id co.nimblehq.kmm.template --bundle-id-staging co.nimblehq.kmm.template.staging --project-name sample --ios-version 14.0

- name: Restore the previous ArkanaKeys's keys
run: |
Expand Down Expand Up @@ -100,8 +105,8 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Decode buildKonfig properties
run: echo ${{ secrets.BUILD_KONFIG_PROPERTIES }} | base64 --decode > buildKonfig.properties
- name: Set up the necessary config
run: echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties

- name: Run Detekt
run: ./gradlew detekt
Expand Down Expand Up @@ -165,9 +170,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pods-
- name: Decode buildKonfig properties
- name: Set up the necessary config
working-directory: ./sample
run: echo ${{ secrets.BUILD_KONFIG_PROPERTIES }} | base64 --decode > buildKonfig.properties
run: echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties

- name: Generate KMM frameworks for Cocoapods
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ local.properties
xcuserdata
buildKonfig.properties

# Keystore
config/release.keystore

# iOS
ios/Pods/
ios/fastlane/README.md
Expand Down
3 changes: 3 additions & 0 deletions custom/android/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@
#-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
# static <1>$$serializer INSTANCE;
#}

# Suppress: Missing class org.slf4j.impl.StaticLoggerBinder while running R8
-dontwarn org.slf4j.impl.StaticLoggerBinder
52 changes: 52 additions & 0 deletions sample/.github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy production app to Firebase App Distribution
on:
push:
branches:
- main

jobs:
deploy_android:
name: Deploy Android app to Firebase App Distribution
runs-on: ubuntu-latest
timeout-minutes: 30
environment: production
defaults:
run:
working-directory: ./sample
steps:
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'

- name: Checkout source code
uses: actions/checkout@v3

- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches/modules-*
~/.gradle/caches/jars-*
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up the necessary config
run: |
echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties
echo "${{ secrets.ANDROID_SIGNING_PROPERTIES }}" > signing.properties
echo "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" | base64 --decode > config/release.keystore
- name: Build production APK
run: ./gradlew assembleProductionRelease -PversionCode=$GITHUB_RUN_NUMBER

- name: Deploy production to Firebase
uses: wzieba/[email protected]
with:
appId: ${{ vars.ANDROID_FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
groups: nimble
file: sample/android/build/outputs/apk/production/release/android-production-release.apk
49 changes: 49 additions & 0 deletions sample/.github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy staging app to Firebase App Distribution
on:
push:
branches:
- develop

jobs:
deploy_android:
name: Deploy Android app to Firebase App Distribution
runs-on: ubuntu-latest
timeout-minutes: 30
environment: staging
defaults:
run:
working-directory: ./sample
steps:
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'

- name: Checkout source code
uses: actions/checkout@v3

- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches/modules-*
~/.gradle/caches/jars-*
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up the necessary config
run: echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties

- name: Build staging APK
run: ./gradlew assembleStagingDebug -PversionCode=$GITHUB_RUN_NUMBER

- name: Deploy staging to Firebase
uses: wzieba/[email protected]
with:
appId: ${{ vars.ANDROID_FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIAL_FILE_CONTENT }}
groups: nimble
file: sample/android/build/outputs/apk/staging/debug/android-staging-debug.apk
17 changes: 11 additions & 6 deletions sample/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Code analysis, test and generate sample project
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
types: [ opened, edited, reopened, synchronize ]
push:
branches-ignore:
- main
- develop
- 'release/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -47,7 +52,7 @@ jobs:
run: rm -rf sample

- name: Generate the new sample project
run: ./make.sh --bundle-id co.nimblehq.kmm.sample --bundle-id-staging co.nimblehq.kmm.sample.staging --project-name sample --ios-version 14.0
run: ./make.sh --bundle-id co.nimblehq.kmm.template --bundle-id-staging co.nimblehq.kmm.template.staging --project-name sample --ios-version 14.0

- name: Restore the previous ArkanaKeys's keys
run: |
Expand Down Expand Up @@ -100,8 +105,8 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Decode buildKonfig properties
run: echo ${{ secrets.BUILD_KONFIG_PROPERTIES }} | base64 --decode > buildKonfig.properties
- name: Set up the necessary config
run: echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties

- name: Run Detekt
run: ./gradlew detekt
Expand Down Expand Up @@ -165,9 +170,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pods-
- name: Decode buildKonfig properties
- name: Set up the necessary config
working-directory: ./sample
run: echo ${{ secrets.BUILD_KONFIG_PROPERTIES }} | base64 --decode > buildKonfig.properties
run: echo "${{ secrets.BUILD_KONFIG_PROPERTIES }}" > buildKonfig.properties

- name: Generate KMM frameworks for Cocoapods
run: |
Expand Down
3 changes: 3 additions & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ local.properties
xcuserdata
buildKonfig.properties

# Keystore
config/release.keystore

# iOS
ios/Pods/
ios/fastlane/README.md
Expand Down
4 changes: 2 additions & 2 deletions sample/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ val getVersionCode: () -> Int = {
}

android {
namespace = "co.nimblehq.kmm.sample"
namespace = "co.nimblehq.kmm.template"
compileSdk = Versions.ANDROID_COMPILE_SDK

defaultConfig {
applicationId = "co.nimblehq.kmm.sample"
applicationId = "co.nimblehq.kmm.template"
minSdk = Versions.ANDROID_MIN_SDK
targetSdk = Versions.ANDROID_TARGET_SDK
versionCode = getVersionCode()
Expand Down
3 changes: 3 additions & 0 deletions sample/android/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@
#-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
# static <1>$$serializer INSTANCE;
#}

# Suppress: Missing class org.slf4j.impl.StaticLoggerBinder while running R8
-dontwarn org.slf4j.impl.StaticLoggerBinder

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.nimblehq.kmm.sample
package co.nimblehq.kmm.template

import android.app.Application
import co.nimblehq.kmm.sample.di.initKoin
import co.nimblehq.kmm.sample.di.modules.appModule
import co.nimblehq.kmm.sample.di.modules.viewModelModule
import co.nimblehq.kmm.template.di.initKoin
import co.nimblehq.kmm.template.di.modules.appModule
import co.nimblehq.kmm.template.di.modules.viewModelModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import timber.log.Timber
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package co.nimblehq.kmm.sample.di.modules
package co.nimblehq.kmm.template.di.modules

import co.nimblehq.kmm.sample.util.DispatchersProvider
import co.nimblehq.kmm.sample.util.DispatchersProviderImpl
import co.nimblehq.kmm.template.util.DispatchersProvider
import co.nimblehq.kmm.template.util.DispatchersProviderImpl
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
import org.koin.dsl.module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package co.nimblehq.kmm.sample.di.modules
package co.nimblehq.kmm.template.di.modules

import co.nimblehq.kmm.sample.ui.screens.home.HomeViewModel
import co.nimblehq.kmm.template.ui.screens.home.HomeViewModel
import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.dsl.module

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.nimblehq.kmm.sample.extensions
package co.nimblehq.kmm.template.extensions

import android.content.Context
import android.widget.Toast
Expand Down
Loading

0 comments on commit 9f3c513

Please sign in to comment.