From 4a8321a0170805db9fd4bc088f78c075a4ecee81 Mon Sep 17 00:00:00 2001 From: wirtos Date: Sun, 1 Dec 2024 20:19:07 +0200 Subject: [PATCH] Use keystore.properties file for signing --- .github/workflows/android_build.yml | 16 ++++++---------- app/build.gradle | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index bc64361..d11e1f5 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -31,7 +31,7 @@ jobs: distribution: 'temurin' java-version: 11 - - name: Decode Keystore + - name: Decode Keystore and create keystore.properties env: ENCODED_STRING: ${{ secrets.KEYSTORE_BASE_64 }} RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} @@ -40,20 +40,16 @@ jobs: run: | echo $ENCODED_STRING > keystore-b64.txt - base64 -d keystore-b64.txt > keystore.jks + base64 -d keystore-b64.txt > app/keystore.jks + echo "storePassword=$RELEASE_KEYSTORE_PASSWORD" >> keystore.properties + echo "keyPassword=$RELEASE_KEY_PASSWORD" >> keystore.properties + echo "keyAlias=$RELEASE_KEYSTORE_ALIAS" >> keystore.properties + echo "storeFile=keystore.jks" >> keystore.properties - name: Build Release apk - env: - RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} - RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }} - RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }} run: ./gradlew assembleRelease --stacktrace - name: Build Release bundle - env: - RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} - RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }} - RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }} run: ./gradlew bundleRelease --stacktrace - name: Release diff --git a/app/build.gradle b/app/build.gradle index f140462..19f774b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,16 @@ plugins { id 'com.android.application' } +// Create a variable called keystorePropertiesFile, and initialize it to your +// keystore.properties file, in the rootProject folder. +def keystorePropertiesFile = rootProject.file("keystore.properties") + +// Initialize a new Properties() object called keystoreProperties. +def keystoreProperties = new Properties() + +// Load your keystore.properties file into the keystoreProperties object. +keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + android { compileSdk 31 // last ndk version that supports deprecated architectures @@ -15,7 +25,14 @@ android { universalApk true } } - + signingConfigs { + release { + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + } + } defaultConfig { applicationId "com.wirtos.tguydroid" @@ -51,6 +68,7 @@ android { shrinkResources true minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release } debug { debuggable true