From 97085f1c0cb7c33496157e19e77ab819044a7df9 Mon Sep 17 00:00:00 2001 From: bytevictor Date: Fri, 29 Mar 2024 18:03:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20=F0=9F=92=9A=20feat:=20Testing?= =?UTF-8?q?=20github=20action=20to=20build=20Android.apk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/create-android.yml | 77 +++++++++++++++++++++++++++- .gitignore | 4 ++ 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-android.yml b/.github/workflows/create-android.yml index 8835139..23dc838 100644 --- a/.github/workflows/create-android.yml +++ b/.github/workflows/create-android.yml @@ -1,4 +1,79 @@ +name: Build Android +run-name: Creating Production Ready Android App 🚀 on: push: branches: - - master \ No newline at end of file + - master + +jobs: + build: + name: Build APK + runs-on: ubuntu-latest + # TODO: add the default directory - COMMENT IF IT'S NOT IN SUBFOLDER + # defaults: + # run: + # working-directory: ./frontend + steps: + - name: Checkout source + uses: actions/checkout@v3 + # TODO: add your branch to checkout + with: + ref: master + + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: "11" + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 19.x + + - name: install dependencies + run: npm ci + + - name: Create Build Folder + run: npm run build + + - name: Add android folder if not present + run: if [ ! -d "./android" ]; then npx cap add android; fi + + - name: Capacitor update + run: npx cap update + + - name: Capacitor copy + run: npx cap copy + + # TODO: Check for folder structure in README for generating splash screen + - name: Generate icons and splash screen to android folder + run: if [ -d "./resources" ]; then npm install @capacitor/assets --save-dev && npx capacitor-assets generate --android; fi + + - name: Build app bundle + run: cd android && ./gradlew bundle && ./gradlew assembleDebug + + - name: Extract Android signing key from env + run: | + echo "${{ secrets.RELEASE_KEYSTORE }}" > android/release.jks.base64 + base64 -d android/release.jks.base64 > android/release.decrypted.jks + + - name: Sign dev build + run: jarsigner -keystore android/release.decrypted.jks -storepass "${{ secrets.RELEASE_KEYSTORE_PASSWORD }}" -signedjar ./android/app/build/outputs/bundle/release/app-release-signed.aab ./android/app/build/outputs/bundle/release/app-release.aab release + + - name: Check folder content of android output + run: ls ./android/app/build/outputs/bundle/release + + - name: Set Tag + id: current-datetime + run: echo "CURRENT_DATETIME=$(date +'%Y-%m-%d-%H_%M_%S%z')" >> "$GITHUB_OUTPUT" + + - name: Build Release + shell: bash + run: | + hub release create ${{ steps.current-datetime.outputs.CURRENT_DATETIME }} \ + -m ${{ steps.current-datetime.outputs.CURRENT_DATETIME }} \ + -a ./android/app/build/outputs/bundle/release/app-release-signed.aab \ + -a ./android/app/build/outputs/apk/debug/app-debug.apk + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index fd3dbb5..f7f14d9 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +# android keystore +android/*.jks +android/*.jks.base64 \ No newline at end of file