Update qa-build.yml

This commit is contained in:
Aman Singh
2023-02-27 18:42:10 +05:30
committed by GitHub Enterprise
parent b30063cefd
commit 2e77f1967d

View File

@@ -1,43 +1,97 @@
name: "Build Android app"
name: Generate APK CI
on:
workflow_dispatch:
# can add push and pull_request here
inputs:
environment:
description: Choose build environment
required: true
type: choice
options:
- qa
- dev
type:
description: Choose build type
required: true
type: choice
options:
- debug
- release
version_code:
description: Enter app version code (example, 292)
required: false
type: string
version_name:
description: Enter app version name (example, 3.2.1)
required: false
type: string
workflow_call:
inputs:
environment:
description: Build environment passed from caller workflow
required: true
type: string
type:
description: Build type passed from caller workflow
required: true
type: string
env:
KEYSTORE_PASSWORD: android
KEYSTORE_ALIAS: key0
KEYSTORE_ALIAS_PASSWORD: android
jobs:
build:
runs-on: ubuntu-latest
generate:
runs-on: [ android ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Java
uses: actions/setup-java@v2
- name: Checkout
uses: actions/checkout@v3
- name: Override App Version Code
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version_code != ''
run: sed -i 's/def VERSION_CODE = [0-9].*/def VERSION_CODE = ${{ github.event.inputs.version_code }}/g' android/app/build.gradle
- name: Override App Version Name
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version_name != ''
run: sed -i 's/def VERSION_NAME = "[0-9].*"/def VERSION_NAME = "${{ github.event.inputs.version_name }}"/g' android/app/build.gradle
- name: Log Build Metadata
run: |
echo "Commit SHA: ${{ github.sha }}"
echo "Build Environment: ${{ github.event.inputs.environment || inputs.environment }}"
echo "Build Type: ${{ github.event.inputs.type || inputs.type }}"
echo "App Version Code: $(awk '/VERSION_CODE/ {print $4}' app/build.gradle)"
echo "App Version Name: $(awk '/VERSION_NAME/ {print $4}' app/build.gradle | tr -d '"')"
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "adopt"
cache: "gradle"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Node
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: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run Yarn Install
run: |
cd ./packages/app-mobile/
npm i -g corepack
yarn install
- name: Build application
run: |
cd ./packages/app-mobile/android
./gradlew assembleDebug
- name: Upload application
uses: actions/upload-artifact@v2
node-version: 16.x
- name: Run install
uses: borales/actions-yarn@v4
with:
name: app
path: ./packages/app-mobile/android/app/build/outputs/apk/debug/app-debug.apk
retention-days: 3
cmd: install # will run `yarn install` command
- name: Assemble with Stacktrace - QA Debug
if: (github.event.inputs.environment == 'qa' || inputs.environment == 'qa') && (github.event.inputs.type == 'debug' || inputs.type == 'debug')
run: ./gradlew assembleQaDebug --stacktrace
- name: Assemble with Stacktrace - DEV Debug
if: (github.event.inputs.environment == 'dev' || inputs.environment == 'dev') && (github.event.inputs.type == 'debug' || inputs.type == 'debug')
run: ./gradlew assembleDevDebug --stacktrace
- name: Assemble with Stacktrace - QA Release
if: (github.event.inputs.environment == 'qa' || inputs.environment == 'qa') && (github.event.inputs.type == 'release' || 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: (github.event.inputs.environment == 'dev' || inputs.environment == 'dev') && (github.event.inputs.type == 'release' || 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-${{ github.event.inputs.environment || inputs.environment }}-${{ github.event.inputs.type || inputs.type }}
path: app/build/outputs/apk/${{ github.event.inputs.environment || inputs.environment }}/${{ github.event.inputs.type || inputs.type }}/
retention-days: 30