From 0951304b3a69158f7a061b2b9910adcd4458c121 Mon Sep 17 00:00:00 2001 From: Jeel Dobariya Date: Fri, 8 Aug 2025 09:40:30 +0530 Subject: [PATCH 1/5] ci: make a workflow that i can trigger to build --- .github/workflows/build-apks.yml | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/build-apks.yml diff --git a/.github/workflows/build-apks.yml b/.github/workflows/build-apks.yml new file mode 100644 index 00000000..26188b3e --- /dev/null +++ b/.github/workflows/build-apks.yml @@ -0,0 +1,72 @@ +# This workflow automates the build process and artifact uploading for an Android app. +# It can be triggered manually, on a push to the 'main' branch, or when a new release is published. + +name: Android CI/CD + +# Define the events that trigger this workflow. +on: + # This allows you to manually trigger the workflow from the GitHub UI. + workflow_dispatch: + + # This triggers the workflow on a push to the 'main' branch. + push: + branches: [main] + + # This triggers the workflow when a release is published. + release: + types: [published] + +# Define the jobs that will run as part of this workflow. +jobs: + # The 'build_and_upload_apk' job handles the core logic. + build_and_upload_apk: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: "17" + + - name: Setup Gradle + uses: gradle/gradle-build-action@v3 + + # Step 4: Build the Android app based on the trigger. + # This step uses an 'if-elif' conditional to determine the correct build variant. + - name: Build APK based on trigger + id: build_apk + run: | + BUILD_VARIANT="" + APK_PATH="" + + # Determine the build variant based on the triggering event. + if [[ "${{ github.event_name }}" == "release" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "Triggered by release or manual dispatch. Building release variant." + BUILD_VARIANT="release" + ./gradlew assembleRelease + APK_PATH=app/build/outputs/apk/release/app-universal-release-unsigned.apk + elif [[ "${{ github.event_name }}" == "push" ]]; then + echo "Triggered by push to 'main' branch. Building staging variant." + BUILD_VARIANT="staging" + ./gradlew assembleStaging + APK_PATH=app/build/outputs/apk/staging/app-universal-staging-unsigned.apk + else + echo "Unknown trigger. Exiting." + exit 1 + fi + + # Set the output variables for the next steps. + echo "build_variant=${BUILD_VARIANT}" >> $GITHUB_OUTPUT + echo "apk_path=${APK_PATH}" >> $GITHUB_OUTPUT + echo "Found APK at: ${{ steps.build_apk.outputs.apk_path }}" + + - name: Upload APK as Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.build_apk.outputs.build_variant }}-apk + path: ${{ steps.build_apk.outputs.apk_path }} + if-no-files-found: error From 5c32a61142a54fc49abd681a3a8c22ab1f568b64 Mon Sep 17 00:00:00 2001 From: Jeel Dobariya Date: Fri, 8 Aug 2025 09:43:38 +0530 Subject: [PATCH 2/5] ci: add a pull request trigger --- .github/workflows/build-apks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-apks.yml b/.github/workflows/build-apks.yml index 26188b3e..7c2f19cc 100644 --- a/.github/workflows/build-apks.yml +++ b/.github/workflows/build-apks.yml @@ -12,6 +12,9 @@ on: push: branches: [main] + pull-requests: + branches: [main] + # This triggers the workflow when a release is published. release: types: [published] From 5747bf256a60d8daa2337b39d941dffe36bb59c6 Mon Sep 17 00:00:00 2001 From: Jeel Dobariya Date: Fri, 8 Aug 2025 09:47:22 +0530 Subject: [PATCH 3/5] ci(bug): fix syntax --- .github/workflows/build-apks.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-apks.yml b/.github/workflows/build-apks.yml index 7c2f19cc..574ebac4 100644 --- a/.github/workflows/build-apks.yml +++ b/.github/workflows/build-apks.yml @@ -1,27 +1,24 @@ # This workflow automates the build process and artifact uploading for an Android app. -# It can be triggered manually, on a push to the 'main' branch, or when a new release is published. name: Android CI/CD -# Define the events that trigger this workflow. on: # This allows you to manually trigger the workflow from the GitHub UI. workflow_dispatch: - # This triggers the workflow on a push to the 'main' branch. push: - branches: [main] + branches: + - main - pull-requests: - branches: [main] + pull_request: + branches: + - main - # This triggers the workflow when a release is published. release: - types: [published] + types: + - published -# Define the jobs that will run as part of this workflow. jobs: - # The 'build_and_upload_apk' job handles the core logic. build_and_upload_apk: runs-on: ubuntu-latest @@ -52,14 +49,11 @@ jobs: BUILD_VARIANT="release" ./gradlew assembleRelease APK_PATH=app/build/outputs/apk/release/app-universal-release-unsigned.apk - elif [[ "${{ github.event_name }}" == "push" ]]; then + else echo "Triggered by push to 'main' branch. Building staging variant." BUILD_VARIANT="staging" ./gradlew assembleStaging APK_PATH=app/build/outputs/apk/staging/app-universal-staging-unsigned.apk - else - echo "Unknown trigger. Exiting." - exit 1 fi # Set the output variables for the next steps. From 70ac2e719aa4b1190083b2ebaa288a07fbfbbc82 Mon Sep 17 00:00:00 2001 From: Jeel Dobariya Date: Fri, 8 Aug 2025 09:59:45 +0530 Subject: [PATCH 4/5] ci: add permissions --- .github/workflows/build-apks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-apks.yml b/.github/workflows/build-apks.yml index 574ebac4..f5932c21 100644 --- a/.github/workflows/build-apks.yml +++ b/.github/workflows/build-apks.yml @@ -35,6 +35,9 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v3 + - name: Grant execute permission to gradlew + run: chmod +x gradlew + # Step 4: Build the Android app based on the trigger. # This step uses an 'if-elif' conditional to determine the correct build variant. - name: Build APK based on trigger From b18cad60f19ec0a810e0e17fbc855c80a4ff8dcd Mon Sep 17 00:00:00 2001 From: Jeel Dobariya Date: Fri, 8 Aug 2025 10:06:55 +0530 Subject: [PATCH 5/5] docs: add badge to readme --- .github/workflows/build-apks.yml | 5 +---- README.md | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-apks.yml b/.github/workflows/build-apks.yml index f5932c21..414fcc1f 100644 --- a/.github/workflows/build-apks.yml +++ b/.github/workflows/build-apks.yml @@ -10,12 +10,9 @@ on: branches: - main - pull_request: - branches: - - main - release: types: + - created - published jobs: diff --git a/README.md b/README.md index 5555b45b..032f7b38 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Passcodes +[![Android CI/CD](https://github.com/JeelDobariya38/Passcodes/actions/workflows/build-apks.yml/badge.svg)](https://github.com/JeelDobariya38/Passcodes/actions/workflows/build-apks.yml) + A android app that take down the headace of remember passwords. It is open source solutions that help you in keep your passwords safe and secure in your own local storage without ever need to push them to cloud. > [!WARNING]