Android CI #9
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 CI | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Application version' | |
required: true | |
default: '0.1' | |
jobs: | |
build: | |
name: Build Signed APK | |
runs-on: ubuntu-latest | |
env: | |
APP_NAME: 'Bouddica Client' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# Here we need to decode keystore.jks from base64 string and place it | |
# in the folder specified in the release signing configuration | |
- name: Decode Keystore | |
id: decode_keystore | |
uses: timheuer/base64-to-file@v1.2 | |
with: | |
fileName: 'android_keystore.jks' | |
fileDir: 'app/keystore/' # Updated relative path | |
encodedString: ${{ secrets.KEYSTORE }} | |
# Debug helper step | |
- name: Debug Keystore Placement | |
run: ls -R app/keystore/ | |
# Build and sign APK ("-x test" argument is used to skip tests) | |
- name: Build APK | |
run: ./gradlew :app:assembleRelease -x test | |
env: | |
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} | |
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} | |
- name: Debug Release Directory | |
run: ls -R app/build/outputs/apk/release/ | |
# Show information about the APK's signing certificates | |
- name: Verify Signature | |
run: | | |
$ANDROID_SDK_ROOT/build-tools/33.0.1/apksigner verify --print-certs app/build/outputs/apk/release/${APP_NAME}_${{ github.event.inputs.version }}.apk | |
# Save the APK after the Build job is complete to publish it as a Github release in the next job | |
- name: Upload APK | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: "${APP_NAME}" | |
path: app/build/outputs/apk/release/${APP_NAME}_${{ github.event.inputs.version }}.apk | |
release: | |
name: Release APK | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download APK from build | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${APP_NAME} | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ github.event.inputs.version }} | |
name: Release v${{ github.event.inputs.version }} | |
draft: false | |
prerelease: false | |
files: ${APP_NAME}/${APP_NAME}_${{ github.event.inputs.version }}.apk |