Skip to content

Commit

Permalink
setup app release
Browse files Browse the repository at this point in the history
  • Loading branch information
joelkanyi committed Jul 3, 2024
1 parent f1b6f52 commit d761a66
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 110 deletions.
73 changes: 0 additions & 73 deletions .github/workflows/deploy.yaml

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release

on:
push:
tags:
- '*'

defaults:
run:
shell: bash

jobs:
release_android:
name: Release Android App
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v3

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: gradle

- name: Make gradle executable
run: chmod +x ./gradlew

- name: Get local.properties from secrets
run: echo "${{secrets.LOCAL_PROPERTIES }}" > $GITHUB_WORKSPACE/local.properties

- name: Build app
run: ./gradlew assembleRelease --stacktrace

- name: Sign APK
id: sign
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}

- name: Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: android-app
if-no-files-found: ignore
path: app/build/outputs/apk/release/*.apk

- name: Release
uses: softprops/action-gh-release@a485adba73bc95d9848c86e019d675bac99de0ed
with:
prerelease: ${{ contains(github.event.inputs.version, '-rc') || contains(github.event.inputs.version, '-b') || contains(github.event.inputs.version, '-a') }}
files: |
app/build/outputs/apk/release/*.apk
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}

changelog:
name: Changelog
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/config/configuration.json"
commitMode: true
ignorePreReleases: ${{ !contains(github.ref, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release
uses: softprops/action-gh-release@a485adba73bc95d9848c86e019d675bac99de0ed
with:
body: ${{steps.github_release.outputs.changelog}}
prerelease: ${{ contains(github.event.inputs.version, '-rc') || contains(github.event.inputs.version, '-b') || contains(github.event.inputs.version, '-a') }}
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .idea/git_toolbox_blame.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 27 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,47 @@ android {
}
}

signingConfigs {
getByName("debug") {
storeFile = file("../keystore/key")
keyAlias = "key0"
keyPassword = "muviz@2022"
storePassword = "muviz@2022"
}
register("release") {
storeFile = file("../keystore/key")
keyAlias = "key0"
keyPassword = "muviz@2022"
storePassword = "muviz@2022"
}
}

buildTypes {
debug {
versionNameSuffix = " - debug-1"
applicationIdSuffix = ".debug"
buildConfigField("int", "PATCH_VERSION_CODE", "1")
signingConfig = signingConfigs.getByName("debug")

val apiKey: String = gradleLocalProperties(rootDir, providers).getProperty("API_KEY") ?: ""
buildConfigField("String", "API_KEY", "\"$apiKey\"")
isDebuggable = false
}

getByName("release") {
isMinifyEnabled = true
isShrinkResources = true

val apiKey: String = gradleLocalProperties(rootDir, providers).getProperty("API_KEY") ?: ""
buildConfigField("String", "API_KEY", "\"$apiKey\"")

proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)

// PATCH_VERSION_CODE is always -1 for release builds.
buildConfigField("int", "PATCH_VERSION_CODE", "-1")
signingConfig = signingConfigs.getByName("release")

val apiKey: String = gradleLocalProperties(rootDir, providers).getProperty("API_KEY") ?: ""
buildConfigField("String", "API_KEY", "\"$apiKey\"")
}
}
compileOptions {
Expand Down
39 changes: 6 additions & 33 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,77 +1,50 @@
## Retrofit
## https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro

# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

## OkHttp
## https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro

# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform

## Gson
## https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg

# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

## Dagger
## https://github.com/google/dagger/blob/master/java/dagger/android/proguard.cfg

Expand All @@ -80,18 +53,18 @@
## Coroutines
## https://github.com/Kotlin/kotlinx.coroutines/blob/master/core/kotlinx-coroutines-core/resources/META-INF/proguard/coroutines.pro

# ServiceLoader support
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}

# Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}

-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile

-optimizations !code/allocation/variable
-optimizations !code/allocation/variable

-keepclassmembers enum * { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ fun SharedTransitionScope.FilmDetailsScreenContent(
) {
LazyColumn(
modifier = Modifier
.padding(it)
.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Expand Down
Binary file added keystore/key
Binary file not shown.

0 comments on commit d761a66

Please sign in to comment.