Skip to content

Commit bf7e0aa

Browse files
committed
[BOOK-223] chore: Firebase App Distribution을 통한 CD 환경 구축
1 parent 066dc58 commit bf7e0aa

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

.github/workflows/android-cd.yml

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

0 commit comments

Comments
 (0)