Skip to content

Commit

Permalink
[Feature] App distribution CI CD Added
Browse files Browse the repository at this point in the history
[Feature] App distribution CI CD Added
  • Loading branch information
dlgocks1 authored Dec 3, 2023
2 parents 90afd7c + a218cda commit d13a96f
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 10 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/app-distribution-ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build & upload to Firebase App Distribution

on:
push:
branches: [ dev ]
workflow_dispatch: # 수동 실행 옵션 (생략가능)

jobs:
build:
runs-on: ubuntu-latest

env:
LOCAL_PROPERTIES_CONTENTS: ${{ secrets.LOCAL_PROPERTIES_CONTENTS }}
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}

steps:
- uses: actions/checkout@v1

- name: set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: grant permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Create local.properties
run: echo "$LOCAL_PROPERTIES_CONTENTS" > local.properties

- name: Create google-services.json
run: echo "$GOOGLE_SERVICES_JSON" > app/google-services.json

- name: build release
run: ./gradlew assembleDebug

- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: winey-team
# file: app/build/outputs/apk/release/app-release-unsigned.apk
file: app/build/outputs/apk/debug/app-debug.apk

# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Setup JDK 11
# uses: actions/setup-java@v3
# with:
# distribution: "zulu"
# java-version: 11
#
# - name: Setup Android SDK
# uses: android-actions/setup-android@v2
#
# - name: Grant execute permission for gradlew
# run: chmod +x gradlew
#
# - name: Decrypt secrets.tar.gpg
# run: gpg --quiet --batch --yes --always-trust --decrypt --passphrase="$SECRET_GPG_PASSWORD" --output secrets.tar secrets.tar.gpg
# env:
# SECRET_GPG_PASSWORD: ${{ secrets.SECRET_GPG_PASSWORD }}
#
# - name: Unzip secrets.tar
# run: tar xvf secrets.tar
#
# - name: Build release universal apk
# run: ./gradlew presentation:packageReleaseUniversalApk
#
# - name: Upload apk to Firebase App Distribution
# uses: wzieba/Firebase-Distribution-Github-Action@v1
# with:
# appId: ${{ secrets.FIREBASE_APP_ID }}
# token: ${{ secrets.FIREBASE_TOKEN }}
# groups: runnerbe
# file: presentation/build/outputs/universal_apk/release/presentation-release-universal.apk
# releaseNotesFile: documents/release-note/default-note.txt
5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id(DAGGER_HILT_ANDROID)
id(KOTLIN_KAPT)
}
id("com.google.gms.google-services")
}

val properties = Properties().apply {
Expand Down Expand Up @@ -91,7 +92,9 @@ dependencies {
implementation(project(":feature:mypage"))
implementation("com.kakao.sdk:v2-user:2.15.0") // 카카오 로그인
implementation("com.google.android.gms:play-services-auth:20.6.0")

implementation(platform("com.google.firebase:firebase-bom:32.6.0"))
implementation("com.google.firebase:firebase-analytics")

with(Dependency) {
implementation(ANDROID_CORE_KTX)
implementation(APPCOMPAT)
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ buildscript {
dependencies {
classpath(Dependency.HILT_ANDROID_GRADLE_PLUGIN)
classpath(Dependency.KOTLIN_GRADLE_PLUGIN)
classpath("com.android.tools.build:gradle:8.0.2")
}
}
// 모든 하위 프로젝트/모듈에 공통적인 구성 옵션을 추가하는 최상위 빌드
Expand All @@ -12,4 +13,5 @@ plugins {
id(JETBRAINS_KOTLIN_ANDROID) version Versions.KOTLIN apply false
id(DAGGER_HILT_PLUGIN) version Versions.HILT apply false
}
id("com.google.gms.google-services") version "4.4.0" apply false
}
2 changes: 1 addition & 1 deletion data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
implementation(CONVERTER_GSON)
implementation(OKHTTP)
implementation(LOGGING_INTERCEPTOR)
debugImplementation(CHUCKER_LIBRARY)
implementation(CHUCKER_LIBRARY)
testImplementation(JUNIT)
}
}
10 changes: 10 additions & 0 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ android {
"GOOGLE_OAUTH_CLIENT_SECRET",
properties["google.oauth.client.secret"] as String
)
buildConfigField(
"String",
"DEBUG_ACCESSTOKEN",
properties["debug.access.token"] as String
)
buildConfigField(
"String",
"DEBUG_REFRESHTOKEN",
properties["debug.refresh.token"] as String
)
}

buildTypes {
Expand Down
16 changes: 10 additions & 6 deletions feature/auth/src/main/java/com/teamwiney/auth/login/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ fun LoginScreen(
effectFlow.collectLatest { effect ->
when (effect) {
is LoginContract.Effect.NavigateTo -> {
if(effect.destination==HomeDestinations.ROUTE){
if (effect.destination == HomeDestinations.ROUTE) {
onInit()
}
appState.navigate(effect.destination,effect.navOptions)
appState.navigate(effect.destination, effect.navOptions)
}

is LoginContract.Effect.ShowSnackBar -> {
Expand Down Expand Up @@ -140,15 +140,19 @@ fun LoginScreen(
}
// 홈화면 테스트용 아이콘
SocialLoginButton(drawable = R.mipmap.img_lock) {
onInit()
appState.navigate(HomeDestinations.ROUTE) {
popUpTo(AuthDestinations.Login.ROUTE) {
inclusive = true
appState.showSnackbar("홈 화면 테스트 입니다.")
viewModel.testLogin {
onInit()
appState.navigate(HomeDestinations.ROUTE) {
popUpTo(AuthDestinations.Login.ROUTE) {
inclusive = true
}
}
}
}
// 회원가입 테스트용 아이콘
SocialLoginButton(drawable = R.mipmap.img_winey_logo_title) {
appState.showSnackbar("회원가입 화면 테스트 입니다.")
appState.navigate("${AuthDestinations.SignUp.ROUTE}?userId=15")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.teamwiney.core.common.navigation.HomeDestinations
import com.teamwiney.core.common.util.Constants.ACCESS_TOKEN
import com.teamwiney.core.common.util.Constants.LOGIN_TYPE
import com.teamwiney.core.common.util.Constants.REFRESH_TOKEN
import com.teamwiney.feature.auth.BuildConfig
import com.teamwiney.data.network.adapter.ApiResult
import com.teamwiney.data.network.model.response.SocialLogin
import com.teamwiney.data.network.service.SocialType
Expand All @@ -25,6 +26,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -112,6 +114,14 @@ class LoginViewModel @Inject constructor(
is ApiResult.Success -> {
val userStatus = result.data.result.userStatus
if (userStatus == SocialLogin.USER_STATUS_ACTIVE) {
Log.i(
"[ACCESS_TOKEN]",
"accessToken: ${result.data.result.accessToken}"
)
Log.i(
"[REFRESH_TOKEN]",
"refreshToken: ${result.data.result.refreshToken}"
)
dataStoreRepository.setStringValue(
ACCESS_TOKEN,
result.data.result.accessToken
Expand All @@ -122,6 +132,7 @@ class LoginViewModel @Inject constructor(
)
dataStoreRepository.setStringValue(LOGIN_TYPE, socialType.name)


postEffect(LoginContract.Effect.NavigateTo(
destination = HomeDestinations.ROUTE,
navOptions = navOptions {
Expand All @@ -146,4 +157,22 @@ class LoginViewModel @Inject constructor(
}
}
}

fun testLogin(callback: () -> Unit) = viewModelScope.launch {
val accessToken = BuildConfig.DEBUG_ACCESSTOKEN
val refreshToken = BuildConfig.DEBUG_REFRESHTOKEN

withContext(coroutineContext) {
dataStoreRepository.setStringValue(
ACCESS_TOKEN,
accessToken
)
dataStoreRepository.setStringValue(
REFRESH_TOKEN,
refreshToken
)
}
callback()
}

}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jul 10 17:33:03 KST 2023
#Mon Dec 04 01:21:47 KST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit d13a96f

Please sign in to comment.