diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2eb395b6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: Build application + +on: + pull_request: + branches: [ main, develop ] + push: + branches: [ main, develop ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + cache: gradle + - name: Build with Gradle + run: ./gradlew build --no-daemon + + - name: Upload results + uses: actions/upload-artifact@v3 + with: + name: SpeakTouch-APKs + path: | + app/build/outputs/apk/debug/SpeakTouch-debug.apk + app/build/outputs/apk/release/SpeakTouch-release-unsigned.apk diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c13a8b00..df1736f3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,6 +25,8 @@ plugins { alias(libs.plugins.dagger) } +val keystorePropertiesFile = rootProject.file("keystore.properties") + java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) @@ -43,13 +45,15 @@ android { compileSdk = 34 buildToolsVersion = "34.0.0" - signingConfigs { - create("release") { - properties(name = "keystore.properties") { properties -> - storeFile = rootProject.file(properties.getProperty("storeFile")) - storePassword = properties.getProperty("storePassword") - keyAlias = properties.getProperty("keyAlias") - keyPassword = properties.getProperty("keyPassword") + if (keystorePropertiesFile.canRead()) { + signingConfigs { + create("release") { + properties(keystorePropertiesFile) { properties -> + storeFile = rootProject.file(properties.getProperty("storeFile")) + storePassword = properties.getProperty("storePassword") + keyAlias = properties.getProperty("keyAlias") + keyPassword = properties.getProperty("keyPassword") + } } } } @@ -75,7 +79,9 @@ android { release { isMinifyEnabled = false - signingConfig = signingConfigs.getByName("release") + if (keystorePropertiesFile.canRead()) { + signingConfig = signingConfigs.getByName("release") + } } debug { @@ -87,6 +93,18 @@ android { } } + applicationVariants.all { + val variant = this + variant.outputs + .map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl } + .forEach { output -> + output.outputFileName = "${rootProject.name}-${buildType.name}.apk" + if (buildType.name == "release" && variant.signingConfig == null) { + output.outputFileName = "${rootProject.name}-${buildType.name}-unsigned.apk" + } + } + } + buildFeatures { buildConfig = true } diff --git a/buildSrc/src/main/kotlin/Project.kt b/buildSrc/src/main/kotlin/Project.kt index 213711dc..b8f15f4d 100644 --- a/buildSrc/src/main/kotlin/Project.kt +++ b/buildSrc/src/main/kotlin/Project.kt @@ -18,15 +18,14 @@ import com.android.build.gradle.internal.dsl.BaseAppModuleExtension import org.gradle.api.Project +import java.io.File import java.io.FileInputStream import java.util.Properties fun Project.properties( - name: String, + file: File, onSuccess: (Properties) -> Unit ) { - val file = rootProject.file(name) - if (file.exists()) { onSuccess( Properties().apply { diff --git a/gradlew b/gradlew old mode 100644 new mode 100755