diff --git a/.github/workflows/build-apks.yml b/.github/workflows/build-apks.yml new file mode 100644 index 00000000..414fcc1f --- /dev/null +++ b/.github/workflows/build-apks.yml @@ -0,0 +1,69 @@ +# This workflow automates the build process and artifact uploading for an Android app. + +name: Android CI/CD + +on: + # This allows you to manually trigger the workflow from the GitHub UI. + workflow_dispatch: + + push: + branches: + - main + + release: + types: + - created + - published + +jobs: + 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 + + - 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 + 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 + 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 + 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 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]