Update CI_STORE_DEPLOY_ANDROID.yaml #21
This file contains 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: CI_STORE_DEPLOY_ANDROID | |
on: | |
push: | |
branches: [main] | |
jobs: | |
setup: | |
name: Setup Environment | |
runs-on: ubuntu-latest | |
env: | |
JAVA_VERSION: 17.0 | |
FLUTTER_VERSION: 3.24.3 | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Setup Java to compile the Android project | |
uses: actions/setup-java@v2 | |
with: | |
distribution: "zulu" | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
# Cache Flutter dependencies | |
- name: Cache Flutter dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.pub-cache | |
key: flutter-${{ env.FLUTTER_VERSION }}-${{ hashFiles('pubspec.yaml') }} | |
# Cache Gradle build files | |
- name: Cache Gradle build files | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
- name: Run flutter pub get | |
run: flutter pub get | |
- name: 🕵️ Analyze to check for bad Dart/Flutter practices | |
run: flutter analyze | |
- name: 📉 Run all app tests | |
run: flutter test | |
build_aab: | |
name: Build AppBundle | |
runs-on: ubuntu-latest | |
env: | |
JAVA_VERSION: 17.0 | |
FLUTTER_VERSION: 3.24.3 | |
AAB_PATH: build/app/outputs/bundle/release/app-release.aab | |
needs: setup | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Setup Java to compile the Android project | |
uses: actions/setup-java@v2 | |
with: | |
distribution: "zulu" | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- name: Build aab | |
run: flutter build appbundle | |
- name: Upload generated aab to the artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: aab-stores | |
path: ${{ env.AAB_PATH }} | |
deploy: | |
name: Deploy to Play Store | |
runs-on: ubuntu-latest | |
env: | |
AAB_PATH: build/app/outputs/bundle/release/app-release.aab | |
KEYSTORE_PATH: android/upload-keystore.jks | |
KEY_PROPS_PATH: android/key.properties | |
SERVICE_ACCOUNT_PATH: store_credentials.json | |
PACKAGE_NAME: tech.bunnie.hub_finder | |
needs: build_aab | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Decode Android keystore | |
run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.KEYSTORE_PATH }} | |
- name: Decode Android key properties | |
run: echo "${{ secrets.ANDROID_KEY_PROPERTIES }}" | base64 --decode > ${{ env.KEY_PROPS_PATH }} | |
- name: Decode Android Service Account | |
run: echo "${{ secrets.PRODUCTION_CREDENTIAL_FILE }}" | base64 --decode > ${{ env.SERVICE_ACCOUNT_PATH }} | |
- name: Deploy to Play Store (Internal testing) | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: '${{ secrets.SERVICE_ACCOUNT_JSON }}' | |
packageName: ${{ env.PACKAGE_NAME }} | |
releaseFiles: ${{ env.AAB_PATH }} | |
track: internal |