104 lines
5.3 KiB
YAML
104 lines
5.3 KiB
YAML
name: generate-apk
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
description: Choose build environment
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- QA
|
|
- Prod
|
|
flavor:
|
|
description: Choose build flavour
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- fieldAgents
|
|
- callingAgents
|
|
type:
|
|
description: Choose build type
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- release
|
|
version_code:
|
|
description: Enter app version code (example, 292)
|
|
required: true
|
|
type: string
|
|
default: "292"
|
|
version_name:
|
|
description: Enter app version name (example, 3.2.1)
|
|
required: true
|
|
type: string
|
|
default: "3.2.1"
|
|
jobs:
|
|
generate:
|
|
runs-on: [ default ]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
token: ${{ secrets.MY_REPO_PAT }}
|
|
submodules: recursive
|
|
- name: update codepush key QA
|
|
if: (github.event.inputs.environment == 'QA' || inputs.environment == 'QA')
|
|
run: sed -i "s/pastekeyhere/${{ secrets.CODEPUSH_QA_KEY }}/" android/app/src/main/res/values/strings.xml && cat android/app/src/main/res/values/strings.xml
|
|
- name: update codepush key PROD
|
|
if: (github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod')
|
|
run: sed -i "s/pastekeyhere/${{ secrets.CODEPUSH_PROD_KEY }}/" android/app/src/main/res/values/strings.xml && cat android/app/src/main/res/values/strings.xml
|
|
- name: Generate keystore
|
|
if: (github.event.inputs.type == 'release' || inputs.type == 'release')
|
|
run: echo "${{ secrets.KEY_STORE }}" > keystore.asc && gpg -d --passphrase "${{ secrets.PASSPHARASE }}" --batch keystore.asc > android/app/my-upload-key.keystore
|
|
- name: Set Node.js 16.x
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16.x
|
|
- name: Install yarn
|
|
run: npm install --global yarn
|
|
- name: Install dependency
|
|
run: yarn
|
|
- 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 18
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: 18
|
|
distribution: adopt
|
|
- name: Setup Android SDK
|
|
uses: navi-synced-actions/setup-android@v2
|
|
- name: Grant execute permission for gradlew
|
|
run: chmod +x android/gradlew
|
|
- name: Create local.properties
|
|
run: cd android && touch local.properties && echo "sdk.dir = /home/USERNAME/Android/Sdk" > local.properties
|
|
- name: Assemble with Stacktrace - Field QA release
|
|
if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA') && (github.event.flavor.type == 'fieldAgents' || inputs.flavor == 'fieldAgents'))
|
|
run: yarn move:qa && cd android && ./gradlew assemblefieldAgentsQARelease
|
|
- name: Assemble with Stacktrace - Field PROD release
|
|
if: ((github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod') && (github.event.flavor.type == 'fieldAgents' || inputs.flavor == 'fieldAgents'))
|
|
run: yarn move:prod && cd android && ./gradlew assemblefieldAgentsProdRelease
|
|
- name: Assemble with Stacktrace - Calling QA release
|
|
if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA') && (github.event.flavor.type == 'callingAgents' || inputs.flavor == 'callingAgents'))
|
|
run: yarn move:qa && cd android && ./gradlew assemblecallingAgentsQARelease
|
|
- name: Assemble with Stacktrace - Calling PROD release
|
|
if: ((github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod') && (github.event.flavor.type == 'callingAgents' || inputs.flavor == 'callingAgents'))
|
|
run: yarn move:prod && cd android && ./gradlew assemblefieldAgentsProdRelease
|
|
- name: Upload APK as Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: app-${{ github.event.inputs.type || inputs.type }}-v${{ github.event.inputs.version_code || inputs.version_code }}-name-${{github.event.inputs.version_name || inputs.version_name}}
|
|
path: android/app/build/outputs/apk/${{ github.event.inputs.flavor || inputs.flavor }}${{github.event.inputs.environment || inputs.environment}}/${{github.event.inputs.type || inputs.type}}
|
|
retention-days: 30
|