From 3f5d6eda6606d3e09ff3e483a3d9292f844179bb Mon Sep 17 00:00:00 2001 From: SSimco <37044560+SSimco@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:28:50 +0300 Subject: [PATCH] Added ci for building the android app --- .github/workflows/android_build.yml | 51 +++++++++++++++++++++++++++++ src/android/app/build.gradle | 23 +++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/android_build.yml diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml new file mode 100644 index 00000000..eacc5c26 --- /dev/null +++ b/.github/workflows/android_build.yml @@ -0,0 +1,51 @@ +name: Android build + +on: + workflow_dispatch: + push: + branches: ["android"] + pull_request: + branches: ["android"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + submodules: "recursive" + fetch-depth: 0 + + - name: Fetch full history for vcpkg submodule + run: | + cd dependencies/vcpkg + git fetch --unshallow + git pull --all + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + + - name: Build Cemu for Android + env: + ANDROID_STORE_FILE_BASE64: ${{ secrets.ANDROID_STORE_FILE_BASE64 }} + ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }} + ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} + run: | + cd ./src/android + base64 --decode <<< "${ANDROID_STORE_FILE_BASE64}" > store.jks + ANDROID_STORE_FILE=$(pwd)/store.jks + echo -e "keyStorePassword=$ANDROID_KEY_STORE_PASSWORD\nkeyAlias=$ANDROID_KEY_ALIAS\nstoreFile=$ANDROID_STORE_FILE\n" > keystore.properties + ./gradlew assembleRelease + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: cemu-android + path: | + ./src/android/app/build/outputs/apk/release/*.apk + ./src/android/app/build/outputs/apk/release/*.aab diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle index 7428f8c9..cbae20af 100644 --- a/src/android/app/build.gradle +++ b/src/android/app/build.gradle @@ -1,6 +1,11 @@ plugins { id 'com.android.application' } +def keystorePropertiesFile = rootProject.file("keystore.properties") +def keystoreProperties = new Properties() +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} android { namespace 'info.cemu.Cemu' @@ -18,12 +23,26 @@ android { } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - + var releaseStoreFile = keystoreProperties['storeFile']; + signingConfigs { + if (releaseStoreFile != null) { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyStorePassword'] + storeFile file(releaseStoreFile) + storePassword keystoreProperties['keyStorePassword'] + } + } + } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.debug + if (releaseStoreFile != null) { + signingConfig signingConfigs.release + } else { + signingConfig signingConfigs.debug + } } debug { applicationIdSuffix ".debug"