Skip to content

Commit 8f9a120

Browse files
authored
Merge pull request #31 from YAPP-Github/feature/NDGL-108/add-build-variant-and-network-header
[NDGL-108] Build Variant 설정, API Key Interceptor 추가, 난독화 설정
2 parents e4f080e + 7306636 commit 8f9a120

32 files changed

Lines changed: 193 additions & 241 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI Setup
2+
description: Common setup steps for CI jobs
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Gradle
8+
uses: gradle/actions/setup-gradle@v4
9+
with:
10+
gradle-home-cache-cleanup: true
11+
12+
- name: Set up JDK 21
13+
uses: actions/setup-java@v4
14+
with:
15+
java-version: '21'
16+
distribution: 'temurin'
17+
18+
- name: Grant execute permission for gradlew
19+
run: chmod +x gradlew
20+
shell: bash
21+
22+
- name: Download config files
23+
uses: actions/download-artifact@v4
24+
with:
25+
name: config-files

.github/workflows/android_ci.yml

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,65 @@ on:
66
pull_request:
77
branches: [ "develop" ]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
10-
build:
14+
setup:
1115
runs-on: ubuntu-latest
1216

1317
steps:
14-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up local.properties
21+
run: echo "${{ secrets.LOCAL_PROPERTIES }}" > local.properties
22+
23+
- name: Set up keystore
24+
run: |
25+
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/ndgl.keystore
26+
echo "KEYSTORE_PATH=../app/ndgl.keystore" >> local.properties
27+
echo "KEYSTORE_STORE_PASSWORD=${{ secrets.KEYSTORE_STORE_PASSWORD }}" >> local.properties
28+
echo "KEYSTORE_ALIAS=${{ secrets.KEYSTORE_ALIAS }}" >> local.properties
29+
echo "KEYSTORE_KEY_PASSWORD=${{ secrets.KEYSTORE_KEY_PASSWORD }}" >> local.properties
30+
echo "NDGL_BASE_URL_DEBUG=${{ secrets.NDGL_BASE_URL_DEBUG }}" >> local.properties
31+
echo "NDGL_BASE_URL_RELEASE=${{ secrets.NDGL_BASE_URL_RELEASE }}" >> local.properties
32+
33+
- name: Set up google-services.json
34+
run: |
35+
mkdir -p app/src/debug app/src/release
36+
echo '${{ secrets.GOOGLE_SERVICES_DEBUG }}' | base64 -d > app/src/debug/google-services.json
37+
echo '${{ secrets.GOOGLE_SERVICES_RELEASE }}' | base64 -d > app/src/release/google-services.json
1538
16-
- name: Setup Gradle
17-
uses: gradle/actions/setup-gradle@v4
18-
with:
19-
gradle-home-cache-cleanup: true
39+
- name: Upload config files
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: config-files
43+
retention-days: 1
44+
path: |
45+
local.properties
46+
app/ndgl.keystore
47+
app/src/debug/google-services.json
48+
app/src/release/google-services.json
2049
21-
- name: Set up JDK 21
22-
uses: actions/setup-java@v4
23-
with:
24-
java-version: '21'
25-
distribution: 'temurin'
50+
lint:
51+
needs: setup
52+
runs-on: ubuntu-latest
2653

27-
- name: Grant execute permission for gradlew
28-
run: chmod +x gradlew
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: ./.github/actions/ci-setup
2957

30-
- name: Set up local.properties
31-
run: echo "${{ secrets.LOCAL_PROPERTIES }}" > local.properties
58+
- name: Code style checks
59+
run: ./gradlew ktlintCheck detekt --build-cache --parallel
3260

33-
- name: Set up google-services.json
34-
run: echo '${{ secrets.GOOGLE_SERVICES }}' | base64 -d > app/google-services.json
61+
build:
62+
needs: setup
63+
runs-on: ubuntu-latest
3564

36-
- name: Code style checks
37-
run: ./gradlew ktlintCheck detekt
65+
steps:
66+
- uses: actions/checkout@v4
67+
- uses: ./.github/actions/ci-setup
3868

39-
- name: Run build
40-
run: ./gradlew assembleDebug --stacktrace
69+
- name: Run build
70+
run: ./gradlew assembleDebug --build-cache --parallel --stacktrace

app/build.gradle.kts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,48 @@ plugins {
99
android {
1010
namespace = Configuration.APPLICATION_ID
1111

12-
defaultConfig {
13-
val localProperties = Properties().apply {
14-
load(rootProject.file("local.properties").bufferedReader())
15-
}
12+
val localProperties = Properties().apply {
13+
load(rootProject.file("local.properties").bufferedReader())
14+
}
1615

16+
defaultConfig {
1717
manifestPlaceholders["MAPS_API_KEY"] = localProperties.getProperty("MAPS_API_KEY", "")
1818
}
1919

20+
signingConfigs {
21+
create("release") {
22+
storeFile = file(localProperties.getProperty("KEYSTORE_PATH"))
23+
storePassword = localProperties.getProperty("KEYSTORE_STORE_PASSWORD")
24+
keyAlias = localProperties.getProperty("KEYSTORE_ALIAS")
25+
keyPassword = localProperties.getProperty("KEYSTORE_KEY_PASSWORD")
26+
}
27+
}
28+
2029
buildFeatures {
2130
buildConfig = true
2231
}
2332

2433
buildTypes {
34+
all {
35+
proguardFiles(
36+
getDefaultProguardFile("proguard-android-optimize.txt"),
37+
"proguard-rules.pro",
38+
)
39+
buildConfigField("String", "NDGL_API_KEY", "\"${localProperties.getProperty("NDGL_API_KEY", "")}\"")
40+
}
41+
debug {
42+
applicationIdSuffix = ".debug"
43+
isDebuggable = true
44+
isMinifyEnabled = false
45+
isShrinkResources = false
46+
buildConfigField("String", "NDGL_BASE_URL", "\"${localProperties.getProperty("NDGL_BASE_URL_DEBUG")}\"")
47+
}
2548
release {
49+
signingConfig = signingConfigs.getByName("release")
50+
isDebuggable = false
2651
isMinifyEnabled = true
52+
isShrinkResources = true
53+
buildConfigField("String", "NDGL_BASE_URL", "\"${localProperties.getProperty("NDGL_BASE_URL_RELEASE")}\"")
2754
}
2855
}
2956
}
@@ -36,6 +63,8 @@ dependencies {
3663
implementation(project(":feature:travel"))
3764
implementation(project(":feature:travel-helper"))
3865

66+
implementation(project(":data:core"))
67+
3968
implementation(project(":core:ui"))
4069

4170
implementation(libs.androidx.navigation3.runtime)

app/proguard-rules.pro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818

1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
21+
#-renamesourcefileattribute SourceFile
22+
23+
# j2objc annotations are not available on Android
24+
-dontwarn com.google.j2objc.annotations.ReflectionSupport
25+
-dontwarn com.google.j2objc.annotations.RetainedWith
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">NDGL.debug</string>
3+
</resources>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.yapp.ndgl.di
2+
3+
import com.yapp.ndgl.BuildConfig
4+
import com.yapp.ndgl.data.core.di.ApiKey
5+
import com.yapp.ndgl.data.core.di.BaseUrl
6+
import dagger.Module
7+
import dagger.Provides
8+
import dagger.hilt.InstallIn
9+
import dagger.hilt.components.SingletonComponent
10+
import javax.inject.Singleton
11+
12+
@Module
13+
@InstallIn(SingletonComponent::class)
14+
object AppNetworkModule {
15+
16+
@BaseUrl
17+
@Singleton
18+
@Provides
19+
fun provideBaseUrl(): String = BuildConfig.NDGL_BASE_URL
20+
21+
@ApiKey
22+
@Singleton
23+
@Provides
24+
fun provideApiKey(): String = BuildConfig.NDGL_API_KEY
25+
}

build-logic/src/main/kotlin/NDGLAndroidLibraryPlugin.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import convention.configureTimber
55
import org.gradle.api.Plugin
66
import org.gradle.api.Project
77
import org.gradle.kotlin.dsl.dependencies
8+
import util.libraryExtension
89
import util.libs
910

1011
class NDGLAndroidLibraryPlugin : Plugin<Project> {
@@ -19,6 +20,10 @@ class NDGLAndroidLibraryPlugin : Plugin<Project> {
1920
configureComposeAndroid()
2021
configureTimber()
2122

23+
libraryExtension.defaultConfig {
24+
consumerProguardFiles("consumer-rules.pro")
25+
}
26+
2227
dependencies {
2328
"implementation"(libs.findLibrary("kotlinx-immutable").get())
2429
}

build-logic/src/main/kotlin/NDGLDataPlugin.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import convention.configureTimber
55
import org.gradle.api.Plugin
66
import org.gradle.api.Project
77
import org.gradle.kotlin.dsl.dependencies
8+
import util.libraryExtension
89
import util.libs
910

1011
class NDGLDataPlugin : Plugin<Project> {
@@ -19,6 +20,10 @@ class NDGLDataPlugin : Plugin<Project> {
1920
configureCoroutineAndroid()
2021
configureTimber()
2122

23+
libraryExtension.defaultConfig {
24+
consumerProguardFiles("consumer-rules.pro")
25+
}
26+
2227
if (path != ":data:core") {
2328
dependencies.add("implementation", project(":data:core"))
2429
}

build-logic/src/main/kotlin/convention/KotlinAndroid.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ internal fun Project.configureKotlinAndroid() {
2020
defaultConfig {
2121
minSdk = Configuration.MIN_SDK
2222
}
23-
buildTypes {
24-
getByName("release") {
25-
isMinifyEnabled = false
26-
proguardFiles(
27-
getDefaultProguardFile("proguard-android-optimize.txt"),
28-
"proguard-rules.pro",
29-
)
30-
}
31-
}
3223
compileOptions {
3324
sourceCompatibility = Configuration.JAVA_VERSION
3425
targetCompatibility = Configuration.JAVA_VERSION

core/base/consumer-rules.pro

Whitespace-only changes.

0 commit comments

Comments
 (0)