Reusable GitHub Actions workflow for building and testing Android projects.
Create .github/workflows/android.yml in your Android project:
name: Android CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
build:
uses: krrishnaaaa/android-ci/.github/workflows/build.yml@mainThat's it. This will:
- Check out your code
- Set up JDK 21
- Cache Gradle dependencies
- Build the debug APK
- Run unit tests
- Upload the APK as an artifact
All inputs are optional with sensible defaults:
| Input | Default | Description |
|---|---|---|
java-version |
21 |
JDK version |
gradle-task |
assembleDebug |
Gradle build task |
test-task |
test |
Gradle test task |
run-tests |
true |
Whether to run unit tests |
upload-artifact |
true |
Whether to upload built APK |
artifact-path |
app/build/outputs/apk/debug/*.apk |
Path to artifact |
artifact-name |
debug-apk |
Name for the uploaded artifact |
name: Android CI
on:
push:
branches: [main]
jobs:
build:
uses: krrishnaaaa/android-ci/.github/workflows/build.yml@main
with:
java-version: '17'
gradle-task: 'assembleRelease'
run-tests: false
artifact-path: 'app/build/outputs/apk/release/*.apk'
artifact-name: 'release-apk'