Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AWS credentials for S3 build cache
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
16 changes: 12 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
with:
java-version: 17
distribution: 'temurin'
- name: Clean build
run: ./gradlew clean
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Setup google-services.json (Live)
run: |
mkdir -p ./app/src/live
Expand Down Expand Up @@ -85,8 +89,12 @@ jobs:
with:
java-version: 17
distribution: 'temurin'
- name: Clean build
run: ./gradlew clean
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Setup google-services.json (Staging)
run: |
mkdir -p ./app/src/staging
Expand Down
41 changes: 13 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ on:
branches:
- 'develop'

jobs:
cancel-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

static-check:
jobs:
build:
runs-on: ubuntu-latest
needs: cancel-workflow
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -28,30 +23,20 @@ jobs:
with:
java-version: 17
distribution: 'adopt'
- name: Clean build
run: ./gradlew clean
- name: Run ktlintDebug
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Run ktlint
run: ./gradlew ktlintMainSourceSetCheck
- name: Upload ktlint report
uses: actions/upload-artifact@v4
if: failure()
with:
name: ktlint-result
path: ./**/build/reports/ktlint/**/*.html

build:
runs-on: ubuntu-latest
needs: static-check
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'adopt'
- name: Clean build
run: ./gradlew clean
- name: Setup google-services.json (Staging)
run: |
mkdir -p ./app/src/staging
Expand All @@ -71,4 +56,4 @@ jobs:
${{ secrets.secrets_xml_staging_core_network }}
EOF
- name: Build debug APK
run: ./gradlew assembleStagingDebug --stacktrace
run: ./gradlew assembleStagingDebug --stacktrace
12 changes: 8 additions & 4 deletions .github/workflows/manual_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ jobs:
with:
java-version: 17
distribution: 'adopt'
- name: Clean build
run: ./gradlew clean
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Setup google-services.json (Live)
if: startsWith(github.event.inputs.variant, 'live')
run: |
Expand Down Expand Up @@ -109,7 +113,7 @@ jobs:
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
- name: Upload artifact to Firebase App Distribution (Live)
if: ${{ github.event.inputs.firebase == 'true' && startsWith(github.event.inputs.variant, 'Live') }}
if: ${{ github.event.inputs.firebase == 'true' && startsWith(github.event.inputs.variant, 'live') }}
run: ./gradlew appDistributionUploadLiveRelease
- name: Upload artifact to Firebase App Distribution (Staging)
if: ${{ github.event.inputs.firebase == 'true' && startsWith(github.event.inputs.variant, 'staging') }}
Expand Down Expand Up @@ -141,4 +145,4 @@ jobs:
file_path: './app/build/outputs/apk/staging/release/app-staging-release.apk'
file_name: 'app-staging-release.apk'
file_type: 'apk'
initial_comment: 'staging-release APK'
initial_comment: 'staging-release APK'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/app/src/live/
/app/src/staging/

# Environment variables
.env

# Created by https://www.toptal.com/developers/gitignore/api/androidstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=androidstudio

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ Please request these files from the maintainer if needed.
```
3. Build and run the project using JDK 17.

### Build Cache

CI 빌드 속도 향상을 위해 S3 기반 원격 빌드 캐시를 사용합니다.

**로컬에서 캐시 업로드:**

1. `.env` 파일에 AWS 자격 증명 설정:
```
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
```

2. 캐시 업로드 실행:
```bash
./gradlew warmCache
```

### Deployment

1. Create a `release-${version-code}` branch and modify the version code in `version.properties`.
Expand Down
9 changes: 9 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ android {
}
}

kotlin {
jvmToolchain(17)
}

dependencies {
// Testing
testImplementation(libs.junit)
Expand Down Expand Up @@ -185,3 +189,8 @@ dependencies {
// Desugaring
coreLibraryDesugaring(libs.desugar.jdk.libs)
}

tasks.register("warmCache") {
description = "CI용 빌드 캐시를 S3에 업로드합니다."
dependsOn("ktlintMainSourceSetCheck", "assembleStagingDebug")
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
# org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
android.enableJetifier=true
android.useAndroidX=true
android.useAndroidX=true

# Build Cache
org.gradle.caching=true
32 changes: 32 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@ pluginManagement {
}
}

plugins {
id("com.github.burrunan.s3-build-cache") version "1.8.1"
}

// Load .env file if exists
val envFile = file(".env")
if (envFile.exists()) {
envFile.readLines()
.filter { it.isNotBlank() && !it.startsWith("#") }
.forEach { line ->
val (key, value) = line.split("=", limit = 2)
System.setProperty(key.trim(), value.trim())
}
}

fun envOrNull(name: String): String? = System.getenv(name) ?: System.getProperty(name)

buildCache {
local {
isEnabled = true
}
remote<com.github.burrunan.s3cache.AwsS3BuildCache> {
region = "ap-northeast-2"
bucket = "snutt-android-build-cache"
prefix = "cache/"
isPush = gradle.startParameter.taskNames.any { it.contains("warmCache") }
lookupDefaultAwsCredentials = true
envOrNull("AWS_ACCESS_KEY_ID")?.let { awsAccessKeyId = it }
envOrNull("AWS_SECRET_ACCESS_KEY")?.let { awsSecretKey = it }
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down