Skip to content

Commit

Permalink
Setup app release
Browse files Browse the repository at this point in the history
  • Loading branch information
floschu committed Oct 19, 2024
1 parent 3982736 commit 5f55cff
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 32 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,20 @@

simple hydration reminder app

![logo](.media/icon.png)
![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
83 changes: 59 additions & 24 deletions app/build.gradle → app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
}

Expand Down Expand Up @@ -95,4 +130,4 @@ dependencies {
implementation(libs.room.runtime)
implementation(libs.room.ktx)
ksp(libs.room.compiler)
}
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion settings.gradle → settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "hydro"
include(":app")
include(":app")

0 comments on commit 5f55cff

Please sign in to comment.