From 5f55cffc5880f815778fc9151827717a3a143c9d Mon Sep 17 00:00:00 2001 From: Florian Schuster Date: Sat, 19 Oct 2024 10:52:21 +0200 Subject: [PATCH] Setup app release --- .github/workflows/release.yml | 14 +++-- README.md | 18 +++++- app/{build.gradle => build.gradle.kts} | 83 ++++++++++++++++++-------- app/proguard-rules.pro | 2 +- settings.gradle => settings.gradle.kts | 5 +- 5 files changed, 90 insertions(+), 32 deletions(-) rename app/{build.gradle => build.gradle.kts} (51%) rename settings.gradle => settings.gradle.kts (81%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddb30a3..4c19662 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,23 +36,27 @@ jobs: echo $ENCODED_STRING > keystore-b64.txt base64 -d keystore-b64.txt > app/keystore.jks - - name: "Build Release bundle" + - name: "Build Release" env: SIGNING_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }} SIGNING_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }} SIGNING_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }} - run: ./gradlew :app:bundleRelease + run: ./gradlew :app:assembleRelease :app:bundleRelease - - name: "Upload Release Build to Artifacts" + - name: "Upload Release Builds" uses: actions/upload-artifact@v4 with: name: release-artifacts if-no-files-found: error - path: app/build/outputs/bundle/release/ + path: | + app/build/outputs/apk/release/*.apk + app/build/outputs/bundle/release/*.aab - name: "Create Github Release" uses: softprops/action-gh-release@v2 with: generate_release_notes: true prerelease: true - files: app/build/outputs/bundle/release/app-release.aab + files: | + app/build/outputs/apk/release/*.apk + app/build/outputs/bundle/release/*.aab diff --git a/README.md b/README.md index d55aa84..08bf9d9 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,20 @@ simple hydration reminder app -![logo](.media/icon.png) \ No newline at end of file +![logo](.media/icon.png) + +## how to create a release + +### local +* Set up signing + * put `keystore.jks` into `app` folder + * add `signingKeyAlias`, `signingKeyPassword`, `signingStorePassword` to `local.properties` +* Execute `./gradlew :app:assembleRelease` + +### github +* Set up signing by adding the following secrets to github: + * `KEYSTORE_ENCRYPTED`: base64 encrypted `keystore.jks` file (`base64 -i [Jks FilePath] -o [EncodeFilePath].txt`) + * `KEYSTORE_KEY_ALIAS`: key alias + * `KEYSTORE_KEY_PASSWORD`: key password + * `KEYSTORE_STORE_PASSWORD`: store password +* Push a new commit with version tag (e.g. `v2.0.0-b36`) to `develop` branch \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle.kts similarity index 51% rename from app/build.gradle rename to app/build.gradle.kts index 7da5d7b..def39aa 100644 --- a/app/build.gradle +++ b/app/build.gradle.kts @@ -1,66 +1,101 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + plugins { - alias libs.plugins.android.application - alias libs.plugins.kotlin.android - alias libs.plugins.kotlin.compose - alias libs.plugins.kotlin.serialization - alias libs.plugins.ksp - alias libs.plugins.ktlint - id "kotlin-parcelize" + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.ksp) + alias(libs.plugins.ktlint) + id("kotlin-parcelize") } android { - namespace "at.florianschuster.hydro" - compileSdk 34 + namespace = "at.florianschuster.hydro" + compileSdk = 34 + defaultConfig { - applicationId "at.florianschuster.hydro" - minSdk 30 - targetSdk 34 - versionCode 1 - versionName "1.0.0" + applicationId = "at.florianschuster.hydro" + minSdk = 30 + targetSdk = 34 + versionCode = 1 + versionName = "1.0.0" vectorDrawables { - useSupportLibrary true + useSupportLibrary = true } + ksp { arg("room.schemaLocation", "$projectDir/schemas") } } + lint { abortOnError = true } + + signingConfigs { + create("release") { + storeFile = + if (file("keystore.jks").exists()) { + file("keystore.jks") + } else { + null + } + + val localProperties = gradleLocalProperties(rootDir, providers) + + storePassword = localProperties.getProperty("signingStorePassword") + ?: System.getenv("SIGNING_STORE_PASSWORD") + ?: null + + keyAlias = localProperties.getProperty("signingKeyAlias") + ?: System.getenv("SIGNING_KEY_ALIAS") + ?: null + + keyPassword = localProperties.getProperty("signingKeyPassword") + ?: System.getenv("SIGNING_KEY_PASSWORD") + ?: null + } + } + buildTypes { debug { - debuggable = true + isDebuggable = true applicationIdSuffix = ".debug" } release { - debuggable = false - minifyEnabled = true - shrinkResources = true + isDebuggable = false + isMinifyEnabled = true + isShrinkResources = true proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" ) if (file("keystore.jks").exists()) { signingConfig = signingConfigs.getByName("release") } } } + compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } + kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() } + buildFeatures { - buildConfig true + buildConfig = true } + packagingOptions { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" + excludes += "META-INF/versions/9/previous-compilation-data.bin" } - exclude("META-INF/versions/9/previous-compilation-data.bin") } } @@ -95,4 +130,4 @@ dependencies { implementation(libs.room.runtime) implementation(libs.room.ktx) ksp(libs.room.compiler) -} +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..ff59496 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/settings.gradle b/settings.gradle.kts similarity index 81% rename from settings.gradle rename to settings.gradle.kts index f89b8f9..580fec7 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -1,3 +1,4 @@ +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { repositories { google() @@ -5,6 +6,7 @@ pluginManagement { gradlePluginPortal() } } + dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { @@ -12,5 +14,6 @@ dependencyResolutionManagement { mavenCentral() } } + rootProject.name = "hydro" -include(":app") +include(":app") \ No newline at end of file