Skip to content

Commit

Permalink
Merge pull request #57 from YAPP-Github/refactor/#56-cd-workflow
Browse files Browse the repository at this point in the history
[REFACTOR/YAF-000]CD WorkFlow를 개선합니다.
  • Loading branch information
MoonsuKang authored Jan 30, 2025
2 parents bf8037c + 3e032c4 commit fed4822
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 98 deletions.
202 changes: 105 additions & 97 deletions .github/workflows/android_cd.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,110 @@
name: Orbit CD

on:
push:
branches:
- release
pull_request:
branches:
- release
push:
branches:
- main
pull_request:
branches:
- main

jobs:
cd:
name: Continuous Deployment
runs-on: ubuntu-latest

steps:
# 1. Code Checkout
- name: Checkout code
uses: actions/checkout@v4

# 2. Gradle Cache
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 3. JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'corretto'
cache: gradle


# 4. Grant Execute Permission
- name: Change gradlew permissions
run: chmod +x gradlew

# 5. google-services.json
- name: Decode google-services.json
env:
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }}
run: echo $FIREBASE_SECRET > app/google-services.json

# 6. local.properties
- name: Add local.properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: |
echo "base.url=\"$BASE_URL\"" >> local.properties
echo "sentry.dsn=\"$SENTRY_DSN\"" >> local.properties
# 7. Ktlint
- name: Run Ktlint Check
run: ./gradlew ktlintCheck --stacktrace

# 8. Test Build (Optional)
- name: Run Unit Tests
run: ./gradlew test --stacktrace

# 9. Debug APK Build
- name: Build Debug APK
run: ./gradlew assembleDebug --stacktrace

# 10. Release AAB Build
- name: Build Release AAB
run: ./gradlew bundleRelease --stacktrace

# 11. Release APK Build
- name: Build Release APK
run: ./gradlew assembleRelease --stacktrace

# 12. AAB Artifact Upload
- name: Upload Release AAB
uses: actions/upload-artifact@v3
with:
name: release-aab
path: app/build/outputs/bundle/release/app-release.aab

# 13. APK Artifact Upload
- name: Upload Release APK
uses: actions/upload-artifact@v3
with:
name: release-apk
path: app/build/outputs/apk/release/app-release.apk

# 14. Firebase App Distribution Upload
- name: Upload APK to Firebase App Distribution
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: |
firebase appdistribution:distribute app/build/outputs/apk/release/app-release.apk \
--app ${{ secrets.FIREBASE_APP_ID }} \
--release-notes "새로운 릴리즈 버전입니다." \
--groups "internal-testers"
cd:
name: Continuous Deployment
runs-on: ubuntu-latest

steps:
# 1. Code Checkout
- name: Checkout code
uses: actions/checkout@v4

# 2. Gradle Cache
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 3. JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'corretto'
cache: gradle

# 4. Grant Execute Permission
- name: Change gradlew permissions
run: chmod +x gradlew

# 5. Install Firebase CLI
- name: Install Firebase CLI
run: curl -sL https://firebase.tools | bash

# 6. Decode google-services.json
- name: Decode google-services.json
env:
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }}
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json

# 7. local.properties
- name: Add local.properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
run: |
echo "base.url=\"$BASE_URL\"" >> app/local.properties
# 8. Ktlint
- name: Run Ktlint Check
run: ./gradlew ktlintCheck --stacktrace

# 9. Debug APK Build
- name: Build Debug APK
run: ./gradlew assembleDebug --stacktrace

# 10. Release AAB Build
- name: Build Release AAB
run: ./gradlew bundleRelease --stacktrace

# 11. Release APK Build
- name: Build Release APK
run: ./gradlew assembleRelease --stacktrace

# 12. AAB Artifact Upload
- name: Upload Release AAB
uses: actions/upload-artifact@v3
with:
name: release-aab
path: app/build/outputs/bundle/release/app-release.aab

# 13. APK Artifact Upload
- name: Upload Release APK
uses: actions/upload-artifact@v3
with:
name: release-apk
path: app/build/outputs/apk/release/app-release.apk

# 14. Firebase App Distribution Upload
- name: Upload APK to Firebase App Distribution
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
run: |
firebase appdistribution:distribute app/build/outputs/apk/release/app-release.apk \
--app "$FIREBASE_APP_ID" \
--release-notes "🚀 새로운 릴리즈 버전이 배포되었습니다!" \
--groups "internal-testers"
# 15. Notify Discord
- name: Notify Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{"content": "🚀 새로운 데모 버전이 Firebase App Distribution에 업로드되었습니다!\nAPK 다운로드: https://appdistribution.firebase.google.com"}' \
$DISCORD_WEBHOOK_URL
6 changes: 5 additions & 1 deletion .github/workflows/android_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ jobs:
- name: Decode google-services.json
env:
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }}
run: echo $FIREBASE_SECRET > app/google-services.json
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json

# Debug google-services.json
- name: Debug google-services.json
run: cat app/google-services.json

# Add Local Properties
- name: Add Local Properties
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id("orbit.android.application")
id("orbit.android.compose")
alias(libs.plugins.google.service)
alias(libs.plugins.firebase.app.distribution)
}

android {
Expand Down
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ plugins {
alias(libs.plugins.ksp) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.google.service) apply false
alias(libs.plugins.firebase.app.distribution) apply false
// alias(libs.plugins.sentry) apply false
}

apply {
Expand Down
17 changes: 17 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ okhttp = "4.12.0"
retrofit = "2.11.0"
retrofit-kotlinx-serialization-json = "1.0.0"
coil = "2.4.0"
sentry = "5.0.0"
sentry-android = "8.0.0"
sentry-compose = "8.0.0"

# Google Libraries Versions
google-service = "4.4.2"
firebase-bom = "33.1.1"
firebase-app-distribution = "5.1.0"

## Test
junit = "4.13.2"
Expand Down Expand Up @@ -129,6 +137,12 @@ retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.r
retrofit-kotlin-serialization = { module = "com.squareup.retrofit2:converter-kotlinx-serialization", version.ref = "retrofit" }
okhttp-bom = { group = "com.squareup.okhttp3", name = "okhttp-bom", version.ref = "okhttp" }
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
#sentry-android = { group = "io.sentry", name = "sentry-android", version.ref = "sentry-android" }
#sentry-compose = { group = "io.sentry", name = "sentry-compose", version.ref = "sentry-compose" }

# Google Libraries
firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase-bom" }
firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx" }

## Logging
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
Expand Down Expand Up @@ -161,3 +175,6 @@ android-library = { id = "com.android.library", version.ref = "android-gradle-pl
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
android-test = { id = "com.android.test", version.ref = "android-gradle-plugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
google-service = { id = "com.google.gms.google-services", version.ref = "google-service" }
firebase-app-distribution = { id = "com.google.firebase.appdistribution", version.ref = "firebase-app-distribution" }
#sentry = { id = "io.sentry.android.gradle", version.ref = "sentry" }

0 comments on commit fed4822

Please sign in to comment.