diff --git a/.github/workflows/android-cd.yml b/.github/workflows/android-cd.yml new file mode 100644 index 00000000..256350a6 --- /dev/null +++ b/.github/workflows/android-cd.yml @@ -0,0 +1,107 @@ +name: Android CD + +env: + GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false" + GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true + +on: + pull_request: + branches: + - main + +jobs: + cd-build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # 최근 태그를 확인하기 위해 필요 + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 17 + + - name: Generate reed.jks + run: echo '${{ secrets.REED_JAVA_KEYSTORE }}' | base64 -d > ./reed.jks + + - name: Generate local.properties + run: echo '${{ secrets.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties + + - name: Generate keystore.properties + run: echo '${{ secrets.KEYSTORE_PROPERTIES }}' | base64 -d > ./keystore.properties + + - name: Generate google-services.json + run: echo '${{ secrets.GOOGLE_SERVICES }}' | base64 -d > ./app/google-services.json + + - name: Extract Version Name from ApplicationConstants.kt + run: | + set -euo pipefail + VERSION=$(grep "VERSION_NAME" build-logic/src/main/kotlin/com/ninecraft/booket/convention/ApplicationConstants.kt | sed -E 's/.*VERSION_NAME\s*=\s*"([^"]+)".*/\1/') + if [[ -z "$VERSION" ]]; then + echo "Error: ApplicationConstants.kt에서 VERSION_NAME 값을 추출하지 못했습니다." >&2 + exit 1 + fi + echo "version=v${VERSION}" >> "$GITHUB_OUTPUT" + echo "Version extracted from ApplicationConstants.kt: v${VERSION}" + id: extract_version + + - name: Generate Firebase Release Note + id: firebase_release_note + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + # PR_TITLE은 env에서 안전하게 전달됨 + # 가장 최근 태그 찾기 (현재 버전 이전의 태그) + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + # 릴리스 노트 내용 생성 + NOTES="## 🚀 변경사항: ${PR_TITLE}\n\n" + + if [ -n "$LATEST_TAG" ]; then + NOTES="${NOTES}### 이전 버전($LATEST_TAG)부터의 변경사항:\n" + # 최근 태그부터 현재까지의 커밋만 가져옴 + COMMITS=$(git log --pretty=format:"- %h %s (%an)" ${LATEST_TAG}..HEAD --no-merges) + NOTES="${NOTES}${COMMITS}" + else + NOTES="${NOTES}### 커밋 내역:\n" + # 태그가 없는 경우 최근 10개 커밋만 표시 + COMMITS=$(git log --pretty=format:"- %h %s (%an)" --no-merges -n 10) + NOTES="${NOTES}${COMMITS}\n\n(이전 릴리스 태그가 없어 최근 10개 커밋만 표시)" + fi + + # 환경 변수로 저장 + echo "notes<> $GITHUB_OUTPUT + echo -e "$NOTES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Build Release AAB + run: | + ./gradlew :app:bundleRelease + + - name: Upload Release Build to Artifacts + uses: actions/upload-artifact@v4 + with: + name: release-artifacts + path: app/build/outputs/bundle/release/ + if-no-files-found: error + + - name: Create Github Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.extract_version.outputs.version }} + release_name: ${{ steps.extract_version.outputs.version }} + generate_release_notes: true + + - name: Upload artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: ${{secrets.FIREBASE_RELEASE_APP_ID}} + serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} + groups: testers + file: app/build/outputs/bundle/release/app-release.aab + releaseNotes: ${{ steps.firebase_release_note.outputs.notes }} diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index 97212df5..5a4e56c9 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -36,12 +36,10 @@ jobs: gradle-home-cache-cleanup: true - name: Generate local.properties - run: | - echo '${{ secrets.LOCAL_PROPERTIES }}' >> ./local.properties + run: echo '${{ secrets.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties - name: Generate keystore.properties - run: | - echo '${{ secrets.KEYSTORE_PROPERTIES }}' >> ./keystore.properties + run: echo '${{ secrets.KEYSTORE_PROPERTIES }}' | base64 -d > ./keystore.properties - name: Generate google-services.json run: echo '${{ secrets.GOOGLE_SERVICES }}' | base64 -d > ./app/google-services.json diff --git a/build-logic/src/main/kotlin/AndroidRetrofitConventionPlugin.kt b/build-logic/src/main/kotlin/AndroidRetrofitConventionPlugin.kt index 036c0eb0..3de91288 100644 --- a/build-logic/src/main/kotlin/AndroidRetrofitConventionPlugin.kt +++ b/build-logic/src/main/kotlin/AndroidRetrofitConventionPlugin.kt @@ -17,14 +17,6 @@ internal class AndroidRetrofitConventionPlugin : Plugin { "booket.kotlin.library.serialization", ) - extensions.configure { - configureAndroid(this) - - defaultConfig.apply { - targetSdk = ApplicationConstants.TARGET_SDK - } - } - dependencies { implementation(libs.retrofit) implementation(libs.retrofit.kotlinx.serialization.converter)