From ca356f791a899d43df53e5ebddd58d7d4ec42bb3 Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Tue, 19 Oct 2021 21:47:36 +0700 Subject: [PATCH] add keystore --- .github/workflows/build-release.yml | 29 ++++++++++ .../workflows/gradle-wrapper-validation.yml | 10 ++++ .../hoc/comicapp/ui/register/RegisterVM.kt | 4 +- .../com/hoc/comicapp/plugin/ComicAppPlugin.kt | 51 ++++++++++++++++++ keystore/debug.jks | Bin 0 -> 2473 bytes keystore/debugkey.properties | 4 ++ 6 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-release.yml create mode 100644 .github/workflows/gradle-wrapper-validation.yml create mode 100644 keystore/debug.jks create mode 100644 keystore/debugkey.properties diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 00000000..a6d84848 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,29 @@ +name: Build Release APK + +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Build release APK + run: ./gradlew assembleRelease --warning-mode all --stacktrace + + - name: Upload APK + uses: actions/upload-artifact@v2 + with: + name: app-release + path: app/build/outputs/apk/release/*.apk \ No newline at end of file diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 00000000..cd58806b --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,10 @@ +name: Validate Gradle Wrapper +on: [ push, pull_request ] + +jobs: + validation: + name: "Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.5 + - uses: gradle/wrapper-validation-action@v1.0.4 \ No newline at end of file diff --git a/app/src/main/java/com/hoc/comicapp/ui/register/RegisterVM.kt b/app/src/main/java/com/hoc/comicapp/ui/register/RegisterVM.kt index 156f0ccb..64130ffb 100644 --- a/app/src/main/java/com/hoc/comicapp/ui/register/RegisterVM.kt +++ b/app/src/main/java/com/hoc/comicapp/ui/register/RegisterVM.kt @@ -150,7 +150,7 @@ class RegisterVM( private fun isValidUser(user: User): Boolean { val (email, password, fullName) = user return getEmailError(email) === null && - getPasswordError(password) === null && - getFullNameError(fullName) === null + getPasswordError(password) === null && + getFullNameError(fullName) === null } } diff --git a/buildSrc/src/main/kotlin/com/hoc/comicapp/plugin/ComicAppPlugin.kt b/buildSrc/src/main/kotlin/com/hoc/comicapp/plugin/ComicAppPlugin.kt index 543002df..e926d8f9 100644 --- a/buildSrc/src/main/kotlin/com/hoc/comicapp/plugin/ComicAppPlugin.kt +++ b/buildSrc/src/main/kotlin/com/hoc/comicapp/plugin/ComicAppPlugin.kt @@ -17,6 +17,8 @@ import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import versions +import java.lang.System.getenv +import java.util.Properties private inline val Project.libraryExtension get() = extensions.getByType() private inline val Project.appExtension get() = extensions.getByType() @@ -148,7 +150,54 @@ private fun Project.configAndroidApplication() = appExtension.run { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + signingConfigs { + getByName("debug") { + val keystoreProperties = Properties().apply { + load( + rootProject.file("keystore/debugkey.properties") + .apply { check(exists()) } + .reader() + ) + } + + keyAlias = keystoreProperties["keyAlias"] as String + keyPassword = keystoreProperties["keyPassword"] as String + storeFile = rootProject.file(keystoreProperties["storeFile"] as String).apply { check(exists()) } + storePassword = keystoreProperties["storePassword"] as String + } + + create("release") { + val keystoreProperties by lazy { + Properties().apply { + load( + rootProject.file("keystore/debugkey.properties") + .apply { check(exists()) } + .reader() + ) + } + } + + keyAlias = getenv("keyAlias") ?: keystoreProperties["keyAlias"] as String + keyPassword = getenv("keyPassword") ?: keystoreProperties["keyPassword"] as String + storeFile = (getenv("storeFile")?.let { rootProject.file(it) } + ?: rootProject.file(keystoreProperties["storeFile"] as String)).apply { check(exists()) } + storePassword = getenv("storePassword") ?: keystoreProperties["storePassword"] as String + + // Optional, specify signing versions used + enableV1Signing = true + enableV2Signing = true + } + } + buildTypes { + getByName("debug") { + isMinifyEnabled = false + isShrinkResources = false + + signingConfig = signingConfigs.getByName("debug") + isDebuggable = true + } + getByName("release") { isMinifyEnabled = true isShrinkResources = true @@ -157,6 +206,8 @@ private fun Project.configAndroidApplication() = appExtension.run { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + signingConfig = signingConfigs.getByName("release") + isDebuggable = false } } diff --git a/keystore/debug.jks b/keystore/debug.jks new file mode 100644 index 0000000000000000000000000000000000000000..5dcfc30d95c33424d9d6c9bc2c6d05bc3104169b GIT binary patch literal 2473 zcmY+Ec{mh^8^>qNWyV!@gpAp7j4LtY&RLF-MnfniiyY&YY=v=6&NR7mGsuy3v|-g2 z8XB}l6XRG+Xk1BAV%)6X@A>_9pZ()~zVGw>zVG|j`+RT|cqJbYgrmS+p>UN%tHcc< zAPh*Oz%PI)aGOKh5=VhV{wsn6fGH5tq3wBCZcu^$Z3!ZPd^8Gp2S)*K;FO_=|J#Sh zrNBtm3FT|8FS<)=q?zK@ljkQ?N~Z~YAV3!pOab?1>@4}#;vDy*eFJ@7(bixb(ZnQ)<365MT4n_@0 zJG{)+wRriZ@$>9lf=52!WE2d&L9?k`d|T)Pc#)jbLc?W_>Ikin=TKt+(&xLIPxT-` z&lo*|ZV4y8&qQn8Zpr)n`FjquqE8PDzN61}PKQ;dnq-bQ8o?%1(^W`BW^Gw;ZQeMewum2SrE;*c z>UULiY-c#CA}z;i4(-qfTG3v7e0#}8o?n)zLiUd63LxD>ejM~9N)|Je{Vwre?@OCM zbz%W_b~!t(&4yD)L{O))pZ)=&2i{IfLYGOD257xuSBx)16EB9pyoD}UG>-5>{L;N{ z(zpbK3D^AKgTC6c!7g6Vvx2)E&|%emH}nUc1L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