Skip to content

Commit

Permalink
Checking Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashwat12-egov committed Oct 14, 2024
1 parent 3930c9e commit 21bd69f
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 31 deletions.
104 changes: 85 additions & 19 deletions .github/workflows/flutter-build-apk.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Flutter APK
name: Build APK Workflow

on:
push:
Expand All @@ -9,30 +9,96 @@ on:
- hcmpre-717-github-actions-build-apk # Optionally, run on pull requests targeting the 'main' branch

jobs:
build:
build-apk:
runs-on: ubuntu-latest

steps:
# Checkout the latest code from the repository
- name: Checkout repository
- name: Checkout code
uses: actions/checkout@v3

# Install Flutter dependencies using the official Flutter GitHub action
- name: Setup Flutter
uses: subosito/flutter-action@v2
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
flutter-version: '3.16.5'
java-version: '11'
distribution: 'temurin' # Specify the Java distribution

# Run flutter pub get to fetch dependencies
- name: Install dependencies
run: flutter pub get
- name: Flutter action
uses: subosito/[email protected]
with:
flutter-version: "3.16.5"

- name: Build debug APK
run: ./tools/generate-apk.sh
# Run flutter build apk to build the APK
# Archive the APK as a build artifact so it can be downloaded
- name: Upload APK
uses: actions/upload-artifact@v3
- name: Set up Android SDK
uses: android-actions/setup-android@v2
with:
name: app-release-apk
path: ./apps/health_campaign_field_worker_app/build/app/outputs/flutter-apk/app-release.apk
api-level: 30
build-tools: 30.0.3

- name: Install Dependencies
run: flutter pub get

- name: Run APK build script
env:
ENVIRONMENT: QA # or UAT/DEV/ALL depending on your choice
BUILD_CONFIG: release # or profile depending on your choice
run: yes 1 | bash ./tools/generate-apk.sh


#name: Build Flutter APK
#
#on:
# push:
# branches:
# - hcmpre-717-github-actions-build-apk # This specifies that the workflow will run on any push to the 'main' branch
# pull_request:
# branches:
# - hcmpre-717-github-actions-build-apk # Optionally, run on pull requests targeting the 'main' branch
#
#jobs:
# build:
# runs-on: ubuntu-latest
#
# steps:
# # Checkout the latest code from the repository
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Set up JDK 11
# uses: actions/setup-java@v1
# with:
# java-version: '11'
#
# - name: Display working directory
# run: pwd
#
# - name: List files
# run: ls -R
#
# - name: Build release APK
# working-directory: ./apps/health_campaign_field_worker_app/android
# run: bash ./gradlew assembleRelease --stacktrace
#
# - name: Build release APK
# run: bash ./health_campaign_field_worker_app/android/gradlew assembleRelease --stacktrace
#
# - name: Rename APK
# run:
# mv "./app/build/outputs/apk/release/app-release.apk" "./app/build/outputs/apk/release/${{ env.OUTPUT_NAME }}.apk"
#
# - name: Upload release APK
# uses: actions/upload-artifact@v1
# with:
# name: ${{ env.OUTPUT_NAME }}
# path: app/build/outputs/apk/release/${{ env.OUTPUT_NAME }}.apk
#
# - name: Build release AAB
# run: bash ./gradlew bundleRelease --stacktrace
#
# - name: Rename AAB
# run:
# mv "./app/build/outputs/bundle/release/app-release.aab" "./app/build/outputs/bundle/release/${{ env.OUTPUT_NAME }}.aab"
#
# - name: Upload debug AAB
# uses: actions/upload-artifact@v1
# with:
# name: ${{ env.OUTPUT_NAME }}
# path: app/build/outputs/bundle/release/${{ env.OUTPUT_NAME }}.aab
13 changes: 12 additions & 1 deletion apps/health_campaign_field_worker_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@ if (flutterVersionName == null) {

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'

if (project.hasProperty('USE_GOOGLE_SERVICES')) {
apply plugin: 'com.google.gms.google-services'
}

// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
if (!project.hasProperty('USE_GOOGLE_SERVICES')) {
tasks.whenTaskAdded { task ->
if (task.name.contains("GoogleServices")) {
task.enabled = false
}
}
}
compileSdkVersion 34
ndkVersion flutter.ndkVersion

Expand Down
25 changes: 14 additions & 11 deletions tools/generate-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ build_apk() {
fi
}

# Ask user for environment to build for
echo "Please select an environment to build for (UAT, DEV, QA or ALL):"
read env
env="${env:-ALL}"

# Ask user for build config
echo "Please select a build config (release or profile):"
read build_config
build_config="${build_config:-release}"
# Get environment and build config from GitHub Actions environment variables
env="${ENVIRONMENT:-ALL}"
build_config="${BUILD_CONFIG:-release}"
## Ask user for environment to build for
#echo "Please select an environment to build for (UAT, DEV, QA or ALL):"
#read env
#env="${env:-ALL}"
#
## Ask user for build config
#echo "Please select a build config (release or profile):"
#read build_config
#build_config="${build_config:-release}"

# Build APK for specified environment(s) and build config
if [ "$env" == "ALL" ]; then
Expand All @@ -31,7 +34,7 @@ else
env_list=("$env")
fi

./tools/install_bricks.sh
#./tools/install_bricks.sh

for env_option in "${env_list[@]}"; do
cd "$APP_DIR" || exit
Expand All @@ -52,7 +55,7 @@ for env_option in "${env_list[@]}"; do
cd ../../ || exit

mkdir -p outputs
mv "$APP_DIR/build/app/outputs/flutter-apk/app-$build_config.apk" "outputs/app-$env_option-$build_config.apk"
# mv "$APP_DIR/build/app/outputs/flutter-apk/app-$build_config.apk" "outputs/app-$env_option-$build_config.apk"
done

open outputs
Expand Down

0 comments on commit 21bd69f

Please sign in to comment.