DEV Community

Bennett(he/him)
Bennett(he/him)

Posted on

Release Ionic APK with GitHub Actions

Recently I was tasked with creating CI/CD that would add Android APK to releases in GitHub with every PR to main from an ionic codebase. I had never worked with ionic before and the person working on the codebase wasn’t that cooperative so I decided to dive in and explore the codebase to accomplish my task. Here are the steps I followed.

Step 1.
I created a bash script with all the initial plugins installation for android in the ionic codebase as shown in the image below.
Image description

Step 2.
I installed Cordova globally in the execution context of the workflow: npm i -g cordova
Installed dependencies with: npm i
Step 3.
Since I wasn’t using Android Studio in the workflow, I had to use jetifier so I installed it and run npx jetify to migrate Java, XML, POM, and ProGuard references that point to android.support.* packages, changing them so they point to the corresponding androidx.* packages.(As per docs on jetifier)

Step 4.
I was going to use capacitor to create my android build folder from which I would build the APK so I first built the source codes that generate a .www folder that capacitor uses to generate the android artifacts and then ran:
npx ionic capacitor copy android && npx cap sync android

Step 5.
Move into the android folder and use gradlew to build the final APK with: cd android && ./gradlew assembleDebug
NB: For some reason, it doesn’t work without being in the android folder.

The final APK will be in app/build/outputs/apk/debug/

Top comments (0)