From 8c2a16d9440b06c13f46262517728bf0e685fd48 Mon Sep 17 00:00:00 2001 From: Shivam Goyal Date: Thu, 19 Jan 2023 03:05:56 +0530 Subject: [PATCH] Shivam | Improve Build & Generate APK CI (#4981) * Update generate_apk.yml * Update generate_apk.yml * Update android_build.yml * Update android_checkstyle.yml --- .github/workflows/android_build.yml | 13 +++++-------- .github/workflows/android_checkstyle.yml | 6 +++--- .github/workflows/generate_apk.yml | 24 ++++++++++++------------ 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index 9a661102b0..5478647e67 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -5,6 +5,7 @@ on: branches: [ master, release-*, development ] pull_request: branches: [ master, release-*, development ] + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -16,20 +17,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: set up JDK 11 + - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: 11 + distribution: adopt - name: Setup Android SDK uses: android-actions/setup-android@v2 - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Unit Test (for modules w/o flavors) - run: ./gradlew testDebugUnitTest - - name: Unit Test (for modules w/ flavors) - run: ./gradlew testQaDebugUnitTest - - name: Assemble with Stacktrace + - name: Assemble with Stacktrace - QA Debug run: ./gradlew assembleQaDebug --stacktrace - name: Upload APK as Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/android_checkstyle.yml b/.github/workflows/android_checkstyle.yml index 99c671d723..2e0e811400 100644 --- a/.github/workflows/android_checkstyle.yml +++ b/.github/workflows/android_checkstyle.yml @@ -16,11 +16,11 @@ jobs: uses: actions/checkout@v3 - name: Fetch origin/development run: git fetch origin development - - name: set up JDK 11 + - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: 11 + distribution: adopt - name: Setup Android SDK uses: android-actions/setup-android@v2 - name: Grant execute permission for gradlew diff --git a/.github/workflows/generate_apk.yml b/.github/workflows/generate_apk.yml index 34f6f6737d..4b386cc07f 100644 --- a/.github/workflows/generate_apk.yml +++ b/.github/workflows/generate_apk.yml @@ -26,38 +26,38 @@ env: KEYSTORE_ALIAS_PASSWORD: android jobs: - build: + generate: runs-on: [ self-hosted, android ] steps: - name: Checkout uses: actions/checkout@v3 - - name: set up JDK 11 + - name: Set up JDK 11 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: 11 + distribution: adopt - name: Setup Android SDK uses: android-actions/setup-android@v2 - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Generate release keystore - if: inputs.type == 'release' + - name: Generate Release Keystore + if: github.event.inputs.type == 'release' run: keytool -genkey -v -keystore app/navi-release-key.jks -storepass $KEYSTORE_PASSWORD -alias $KEYSTORE_ALIAS -keypass $KEYSTORE_ALIAS_PASSWORD -keyalg RSA -keysize 2048 -validity 10000 -dname "cn=Android Build CI, ou=Android Team, o=Navi, l=Bengaluru, st=Karnataka, c=IN" - name: Assemble with Stacktrace - QA Debug - if: inputs.environment == 'qa' && inputs.type == 'debug' + if: github.event.inputs.environment == 'qa' && github.event.inputs.type == 'debug' run: ./gradlew assembleQaDebug --stacktrace - name: Assemble with Stacktrace - DEV Debug - if: inputs.environment == 'dev' && inputs.type == 'debug' + if: github.event.inputs.environment == 'dev' && github.event.inputs.type == 'debug' run: ./gradlew assembleDevDebug --stacktrace - name: Assemble with Stacktrace - QA Release - if: inputs.environment == 'qa' && inputs.type == 'release' + if: github.event.inputs.environment == 'qa' && github.event.inputs.type == 'release' run: ./gradlew assembleQaRelease --stacktrace -PRELEASE_STORE_PASSWORD=$KEYSTORE_PASSWORD -PRELEASE_KEY_ALIAS=$KEYSTORE_ALIAS -PRELEASE_KEY_PASSWORD=$KEYSTORE_ALIAS_PASSWORD - name: Assemble with Stacktrace - DEV Release - if: inputs.environment == 'dev' && inputs.type == 'release' + if: github.event.inputs.environment == 'dev' && github.event.inputs.type == 'release' run: ./gradlew assembleDevRelease --stacktrace -PRELEASE_STORE_PASSWORD=$KEYSTORE_PASSWORD -PRELEASE_KEY_ALIAS=$KEYSTORE_ALIAS -PRELEASE_KEY_PASSWORD=$KEYSTORE_ALIAS_PASSWORD - name: Upload APK as Artifact uses: actions/upload-artifact@v3 with: - name: app-${{ inputs.environment }}-${{ inputs.type }} - path: app/build/outputs/apk/${{ inputs.environment }}/${{ inputs.type }}/ + name: app-${{ github.event.inputs.environment }}-${{ github.event.inputs.type }} + path: app/build/outputs/apk/${{ github.event.inputs.environment }}/${{ github.event.inputs.type }}/ retention-days: 30