116 lines
6.3 KiB
YAML
116 lines
6.3 KiB
YAML
name: Generate Build CI
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
description: Build Environment
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- qa
|
|
- prod
|
|
type:
|
|
description: Build Type
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- debug
|
|
- release
|
|
output:
|
|
description: Build Output
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- APK
|
|
- AAB
|
|
version_code:
|
|
description: Version Code (e.g., 301)
|
|
required: false
|
|
type: string
|
|
version_name:
|
|
description: Version Name (e.g., 3.0.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
|
|
output:
|
|
description: Build Output passed from caller workflow
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
print-inputs:
|
|
runs-on: [ default ]
|
|
steps:
|
|
- name: Print Inputs
|
|
run: |
|
|
echo "| Input Key | Input Value |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| :---: | :---: |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Build Environment | ${{ inputs.environment }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Build Type | ${{ inputs.type }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Build Output | ${{ inputs.output }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Version Code | ${{ inputs.version_code || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Version Name | ${{ inputs.version_name || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
|
|
generate:
|
|
runs-on: [ android ]
|
|
defaults:
|
|
run:
|
|
working-directory: android
|
|
needs: [ print-inputs ]
|
|
environment: ${{ inputs.environment }}
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.18.0
|
|
- name: Install Node Modules
|
|
run: npm install
|
|
- name: Override Version Code
|
|
if: github.event_name == 'workflow_dispatch' && inputs.version_code != ''
|
|
run: sed -i 's/def VERSION_CODE = [0-9].*/def VERSION_CODE = ${{ inputs.version_code }}/g' app/build.gradle
|
|
- name: Override Version Name
|
|
if: github.event_name == 'workflow_dispatch' && inputs.version_name != ''
|
|
run: sed -i 's/def VERSION_NAME = "[0-9].*"/def VERSION_NAME = "${{ inputs.version_name }}"/g' app/build.gradle
|
|
- name: Log Build Metadata
|
|
run: |
|
|
echo "Version Code: $(awk '/VERSION_CODE/ {print $4}' app/build.gradle)"
|
|
echo "Version Name: $(awk '/VERSION_NAME/ {print $4}' app/build.gradle | tr -d '"')"
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
- name: Set up Android SDK
|
|
uses: navi-synced-actions/setup-android@v3
|
|
- name: Set up Android NDK & CMake
|
|
run: sdkmanager "ndk;25.2.9519653" "cmake;3.22.1"
|
|
- name: Grant Execute Permission for Gradle Wrapper
|
|
run: chmod +x gradlew
|
|
- name: Export Release Store File
|
|
run: echo ${{ secrets.RELEASE_STORE_FILE }} | base64 -d >> app/navi-release-key.jks
|
|
- name: Build - APK - ${{ inputs.environment }}-${{ inputs.type }}
|
|
if: inputs.output == 'APK'
|
|
run: ./gradlew package${{ inputs.environment }}${{ inputs.type }}UniversalApk -PRELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} -PRELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} -PRELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} -PBASE_URL=${{ secrets.BASE_URL }} -PALFRED_API_KEY=${{ secrets.ALFRED_API_KEY }} -PAPPSFLYER_KEY=${{ secrets.APPSFLYER_KEY }} -PHYPERVERGE_APP_ID=${{ secrets.HYPERVERGE_APP_ID }} -PHYPERVERGE_APP_KEY=${{ secrets.HYPERVERGE_APP_KEY }} -PMOENGAGE_KEY=${{ secrets.MOENGAGE_KEY }} -PMQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} -PMQTT_USERNAME=${{ secrets.MQTT_USERNAME }} -PPULSE_BASE_URL=${{ secrets.PULSE_BASE_URL }} -PSSL_PINNING_KEY=${{ secrets.SSL_PINNING_KEY }} -PXIAOMI_PUSH_APP_ID=${{ secrets.XIAOMI_PUSH_APP_ID }} -PXIAOMI_PUSH_APP_KEY=${{ secrets.XIAOMI_PUSH_APP_KEY }} -PYOUTUBE_KEY=${{ secrets.YOUTUBE_KEY }} -PFACEBOOK_APP_ID=${{ secrets.FACEBOOK_APP_ID }} -PTRUECALLER_KEY=${{ secrets.TRUECALLER_KEY }} -PGI_RAZORPAY_KEY=${{ secrets.GI_RAZORPAY_KEY }} -PGOOGLE_MAPS_KEY=${{ secrets.GOOGLE_MAPS_KEY }} -PCODEPUSH_DEPLOYMENT_KEY=${{ secrets.CODEPUSH_DEPLOYMENT_KEY }}
|
|
- name: Build - AAB - ${{ inputs.environment }}-${{ inputs.type }}
|
|
if: inputs.output == 'AAB'
|
|
run: ./gradlew :app:bundle${{ inputs.environment }}${{ inputs.type }} -PRELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} -PRELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} -PRELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} -PBASE_URL=${{ secrets.BASE_URL }} -PALFRED_API_KEY=${{ secrets.ALFRED_API_KEY }} -PAPPSFLYER_KEY=${{ secrets.APPSFLYER_KEY }} -PHYPERVERGE_APP_ID=${{ secrets.HYPERVERGE_APP_ID }} -PHYPERVERGE_APP_KEY=${{ secrets.HYPERVERGE_APP_KEY }} -PMOENGAGE_KEY=${{ secrets.MOENGAGE_KEY }} -PMQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} -PMQTT_USERNAME=${{ secrets.MQTT_USERNAME }} -PPULSE_BASE_URL=${{ secrets.PULSE_BASE_URL }} -PSSL_PINNING_KEY=${{ secrets.SSL_PINNING_KEY }} -PXIAOMI_PUSH_APP_ID=${{ secrets.XIAOMI_PUSH_APP_ID }} -PXIAOMI_PUSH_APP_KEY=${{ secrets.XIAOMI_PUSH_APP_KEY }} -PYOUTUBE_KEY=${{ secrets.YOUTUBE_KEY }} -PFACEBOOK_APP_ID=${{ secrets.FACEBOOK_APP_ID }} -PTRUECALLER_KEY=${{ secrets.TRUECALLER_KEY }} -PGI_RAZORPAY_KEY=${{ secrets.GI_RAZORPAY_KEY }} -PGOOGLE_MAPS_KEY=${{ secrets.GOOGLE_MAPS_KEY }} -PCODEPUSH_DEPLOYMENT_KEY=${{ secrets.CODEPUSH_DEPLOYMENT_KEY }}
|
|
- name: Upload - ${{ inputs.output }} - ${{ inputs.environment }}-${{ inputs.type }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: app-${{ inputs.environment }}-${{ inputs.type }}
|
|
path: |
|
|
android/app/build/outputs/apk_from_bundle/
|
|
android/app/build/outputs/bundle/
|
|
retention-days: 5
|