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 00000000..5dcfc30d Binary files /dev/null and b/keystore/debug.jks differ diff --git a/keystore/debugkey.properties b/keystore/debugkey.properties new file mode 100644 index 00000000..c03c1ad5 --- /dev/null +++ b/keystore/debugkey.properties @@ -0,0 +1,4 @@ +storePassword=android +keyPassword=android +keyAlias=androiddebugkey +storeFile=keystore/debug.jks \ No newline at end of file