upload artifact app-debug.apk #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android Build | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
# Setup Java JDK 17 | |
- name: Setup Java JDK | |
uses: actions/setup-java@v4.0.0 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
# Set up Android SDK | |
- name: Set up Android SDK | |
uses: android-actions/setup-android@v2 | |
# Change wrapper permissions | |
- name: Change wrapper permissions | |
run: chmod +x ./gradlew | |
# Decode the keystore file from Base64 | |
- name: Decode and save Keystore | |
run: | | |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > $HOME/release-keystore.jks | |
# Pull secrets and add them to local.properties | |
- name: Add secrets to local.properties | |
run: | | |
echo "sdk.dir=$ANDROID_HOME" >> local.properties | |
echo "BASE_URL=${{ secrets.BASE_URL }}" >> local.properties | |
echo "HOSTNAME=${{ secrets.HOSTNAME }}" >> local.properties | |
echo "API_KEY=${{ secrets.API_KEY }}" >> local.properties | |
echo "PIN=${{ secrets.PIN }}" >> local.properties | |
echo "PASSPHRASE=${{ secrets.PASSPHRASE }}" >> local.properties | |
- name: Unit Test | |
run: ./gradlew test | |
- name: Generate Kover HTML Report | |
run: ./gradlew koverHtmlReport | |
- name: Upload Kover HTML Report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Kover HTML Report | |
path: core/build/reports/kover/project-html | |
# Build the debug APK, release APK and AAB with Gradle | |
- name: Build release APK and AAB with Gradle | |
run: ./gradlew bundleRelease assembleRelease assembleDebug | |
# Sign the APK | |
- name: Sign APK | |
run: | | |
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \ | |
-keystore $HOME/release-keystore.jks \ | |
-storepass ${{ secrets.KEYSTORE_PASSWORD }} \ | |
-keypass ${{ secrets.KEY_PASSWORD }} \ | |
app/build/outputs/apk/release/app-release-unsigned.apk \ | |
${{ secrets.KEY_ALIAS }} | |
# Zip align the APK (optional) | |
- name: Zipalign APK | |
run: | | |
$ANDROID_HOME/build-tools/33.0.0/zipalign -v -p 4 \ | |
app/build/outputs/apk/release/app-release-unsigned.apk \ | |
app/build/outputs/apk/release/app-release.apk | |
# Sign the AAB | |
- name: Sign AAB | |
run: | | |
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \ | |
-keystore $HOME/release-keystore.jks \ | |
-storepass ${{ secrets.KEYSTORE_PASSWORD }} \ | |
-keypass ${{ secrets.KEY_PASSWORD }} \ | |
app/build/outputs/bundle/release/app-release.aab \ | |
${{ secrets.KEY_ALIAS }} | |
# Upload the signed APK artifact | |
- name: Upload Signed APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Release APK | |
path: app/build/outputs/apk/release/app-release.apk | |
# Upload the debug APK artifact | |
- name: Upload Debug APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Debug APK | |
path: app/build/outputs/apk/debug/app-debug.apk | |
# Upload the signed AAB artifact | |
- name: Upload Signed AAB | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Release AAB | |
path: app/build/outputs/bundle/release/app-release.aab |