Skip to content

Commit b430c06

Browse files
authored
Merge pull request #110 from YAPP-Github/BOOK-223-chore/#108
chore: Github Action CD 환경 구축
2 parents 7a746c7 + 2b3d194 commit b430c06

File tree

3 files changed

+109
-12
lines changed

3 files changed

+109
-12
lines changed

.github/workflows/android-cd.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Android CD
2+
3+
env:
4+
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false"
5+
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
cd-build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
# 최근 태그를 확인하기 위해 필요
21+
fetch-depth: 0
22+
23+
- name: Set up JDK 17
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: 'corretto'
27+
java-version: 17
28+
29+
- name: Generate reed.jks
30+
run: echo '${{ secrets.REED_JAVA_KEYSTORE }}' | base64 -d > ./reed.jks
31+
32+
- name: Generate local.properties
33+
run: echo '${{ secrets.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties
34+
35+
- name: Generate keystore.properties
36+
run: echo '${{ secrets.KEYSTORE_PROPERTIES }}' | base64 -d > ./keystore.properties
37+
38+
- name: Generate google-services.json
39+
run: echo '${{ secrets.GOOGLE_SERVICES }}' | base64 -d > ./app/google-services.json
40+
41+
- name: Extract Version Name from ApplicationConstants.kt
42+
run: |
43+
set -euo pipefail
44+
VERSION=$(grep "VERSION_NAME" build-logic/src/main/kotlin/com/ninecraft/booket/convention/ApplicationConstants.kt | sed -E 's/.*VERSION_NAME\s*=\s*"([^"]+)".*/\1/')
45+
if [[ -z "$VERSION" ]]; then
46+
echo "Error: ApplicationConstants.kt에서 VERSION_NAME 값을 추출하지 못했습니다." >&2
47+
exit 1
48+
fi
49+
echo "version=v${VERSION}" >> "$GITHUB_OUTPUT"
50+
echo "Version extracted from ApplicationConstants.kt: v${VERSION}"
51+
id: extract_version
52+
53+
- name: Generate Firebase Release Note
54+
id: firebase_release_note
55+
env:
56+
PR_TITLE: ${{ github.event.pull_request.title }}
57+
run: |
58+
# PR_TITLE은 env에서 안전하게 전달됨
59+
# 가장 최근 태그 찾기 (현재 버전 이전의 태그)
60+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
61+
62+
# 릴리스 노트 내용 생성
63+
NOTES="## 🚀 변경사항: ${PR_TITLE}\n\n"
64+
65+
if [ -n "$LATEST_TAG" ]; then
66+
NOTES="${NOTES}### 이전 버전($LATEST_TAG)부터의 변경사항:\n"
67+
# 최근 태그부터 현재까지의 커밋만 가져옴
68+
COMMITS=$(git log --pretty=format:"- %h %s (%an)" ${LATEST_TAG}..HEAD --no-merges)
69+
NOTES="${NOTES}${COMMITS}"
70+
else
71+
NOTES="${NOTES}### 커밋 내역:\n"
72+
# 태그가 없는 경우 최근 10개 커밋만 표시
73+
COMMITS=$(git log --pretty=format:"- %h %s (%an)" --no-merges -n 10)
74+
NOTES="${NOTES}${COMMITS}\n\n(이전 릴리스 태그가 없어 최근 10개 커밋만 표시)"
75+
fi
76+
77+
# 환경 변수로 저장
78+
echo "notes<<EOF" >> $GITHUB_OUTPUT
79+
echo -e "$NOTES" >> $GITHUB_OUTPUT
80+
echo "EOF" >> $GITHUB_OUTPUT
81+
82+
- name: Build Release AAB
83+
run: |
84+
./gradlew :app:bundleRelease
85+
86+
- name: Upload Release Build to Artifacts
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: release-artifacts
90+
path: app/build/outputs/bundle/release/
91+
if-no-files-found: error
92+
93+
- name: Create Github Release
94+
uses: softprops/action-gh-release@v2
95+
with:
96+
tag_name: ${{ steps.extract_version.outputs.version }}
97+
release_name: ${{ steps.extract_version.outputs.version }}
98+
generate_release_notes: true
99+
100+
- name: Upload artifact to Firebase App Distribution
101+
uses: wzieba/Firebase-Distribution-Github-Action@v1
102+
with:
103+
appId: ${{secrets.FIREBASE_RELEASE_APP_ID}}
104+
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
105+
groups: testers
106+
file: app/build/outputs/bundle/release/app-release.aab
107+
releaseNotes: ${{ steps.firebase_release_note.outputs.notes }}

.github/workflows/android-ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ jobs:
3636
gradle-home-cache-cleanup: true
3737

3838
- name: Generate local.properties
39-
run: |
40-
echo '${{ secrets.LOCAL_PROPERTIES }}' >> ./local.properties
39+
run: echo '${{ secrets.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties
4140

4241
- name: Generate keystore.properties
43-
run: |
44-
echo '${{ secrets.KEYSTORE_PROPERTIES }}' >> ./keystore.properties
42+
run: echo '${{ secrets.KEYSTORE_PROPERTIES }}' | base64 -d > ./keystore.properties
4543

4644
- name: Generate google-services.json
4745
run: echo '${{ secrets.GOOGLE_SERVICES }}' | base64 -d > ./app/google-services.json

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ internal class AndroidRetrofitConventionPlugin : Plugin<Project> {
1717
"booket.kotlin.library.serialization",
1818
)
1919

20-
extensions.configure<LibraryExtension> {
21-
configureAndroid(this)
22-
23-
defaultConfig.apply {
24-
targetSdk = ApplicationConstants.TARGET_SDK
25-
}
26-
}
27-
2820
dependencies {
2921
implementation(libs.retrofit)
3022
implementation(libs.retrofit.kotlinx.serialization.converter)

0 commit comments

Comments
 (0)