Merge pull request #418 from projects200/dev #82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Android CI/CD (master) | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| jobs: | |
| # =================================================================== | |
| # CI - 코드 검증 (Lint, Unit Tests) | |
| # =================================================================== | |
| ci-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Decode google-services.json | |
| env: | |
| GOOGLE_SERVICES_JSON_PROD_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_PROD_BASE64 }} | |
| GOOGLE_SERVICES_JSON_DEV_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_DEV_BASE64 }} | |
| run: | | |
| mkdir -p app/src/release | |
| echo $GOOGLE_SERVICES_JSON_PROD_BASE64 | base64 --decode > app/src/release/google-services.json | |
| mkdir -p app/src/debug | |
| echo $GOOGLE_SERVICES_JSON_DEV_BASE64 | base64 --decode > app/src/debug/google-services.json | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Create local.properties | |
| run: | | |
| echo "COGNITO_USER_POOL_ID=${{ secrets.COGNITO_USER_POOL_ID }}" >> local.properties | |
| echo "COGNITO_APP_CLIENT_ID=${{ secrets.COGNITO_APP_CLIENT_ID }}" >> local.properties | |
| echo "COGNITO_REGION=${{ secrets.COGNITO_REGION }}" >> local.properties | |
| echo "KAKAO_NATIVE_APP_KEY=${{ secrets.KAKAO_NATIVE_APP_KEY_DEV }}" >> local.properties | |
| echo "KAKAO_REST_API_KEY=${{ secrets.KAKAO_REST_API_KEY }}" >> local.properties | |
| shell: bash | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x ./gradlew | |
| - name: Clean project | |
| run: ./gradlew clean | |
| - name: Run Android Lint | |
| run: ./gradlew lintRelease | |
| - name: Run Ktlint Check | |
| run: ./gradlew ktlintCheck | |
| - name: Run Unit Tests (Release) | |
| run: ./gradlew testReleaseUnitTest | |
| - name: Decode Release Signing Key for Test | |
| id: decode_key | |
| uses: timheuer/[email protected] | |
| with: | |
| fileName: 'release.jks' | |
| encodedString: ${{ secrets.RELEASE_SIGNING_KEY_BASE64 }} | |
| # =================================================================== | |
| # CD - 빌드 및 배포 | |
| # ci-test Job이 성공하고, 'push' 이벤트일 때만 실행됩니다. | |
| # =================================================================== | |
| cd-deploy: | |
| needs: ci-test | |
| if: github.event_name == 'push' && (needs.ci-test.result == 'success' || needs.ci-test.result == 'skipped') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Decode google-services.json | |
| env: | |
| GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_PROD_BASE64 }} | |
| run: | | |
| mkdir -p app/src/release | |
| echo $GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/src/release/google-services.json | |
| - name: Create local.properties | |
| run: | | |
| echo "COGNITO_USER_POOL_ID=${{ secrets.COGNITO_USER_POOL_ID }}" >> local.properties | |
| echo "COGNITO_APP_CLIENT_ID=${{ secrets.COGNITO_APP_CLIENT_ID }}" >> local.properties | |
| echo "COGNITO_REGION=${{ secrets.COGNITO_REGION }}" >> local.properties | |
| echo "KAKAO_NATIVE_APP_KEY=${{ secrets.KAKAO_NATIVE_APP_KEY_DEV }}" >> local.properties | |
| echo "KAKAO_REST_API_KEY=${{ secrets.KAKAO_REST_API_KEY }}" >> local.properties | |
| shell: bash | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x ./gradlew | |
| - name: Decode Release Signing Key for Deploy | |
| id: decode_key | |
| uses: timheuer/[email protected] | |
| with: | |
| fileName: 'release.jks' | |
| encodedString: ${{ secrets.RELEASE_SIGNING_KEY_BASE64 }} | |
| - name: Build Release App Bundle (AAB) | |
| shell: bash | |
| run: | | |
| ./gradlew bundleRelease \ | |
| -Pandroid.injected.signing.store.file=${{ steps.decode_key.outputs.filePath }} \ | |
| -Pandroid.injected.signing.store.password=${{ secrets.RELEASE_STORE_PASSWORD }} \ | |
| -Pandroid.injected.signing.key.alias=${{ secrets.RELEASE_KEY_ALIAS }} \ | |
| -Pandroid.injected.signing.key.password=${{ secrets.RELEASE_KEY_PASSWORD }} | |
| - name: Decode service account JSON | |
| id: decode_json | |
| uses: timheuer/[email protected] | |
| with: | |
| fileName: 'service_account_key.json' | |
| encodedString: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} | |
| - name: Upload Release AAB to Google Play (Internal Testing) | |
| uses: r0adkll/upload-google-play@v1 | |
| with: | |
| serviceAccountJson: ${{ steps.decode_json.outputs.filePath }} | |
| packageName: com.project200.undabang | |
| releaseFiles: app/build/outputs/bundle/release/app-release.aab | |
| track: internal | |
| status: completed |