Skip to content

Commit

Permalink
Merge pull request #117 from NeoA11y/ci/action-build
Browse files Browse the repository at this point in the history
Build and upload APKs as artifacts
  • Loading branch information
Irineu333 authored Nov 28, 2023
2 parents df538c5 + bb44f21 commit aa12b4b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 11 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 26 additions & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ plugins {
alias(libs.plugins.dagger)
}

val keystorePropertiesFile = rootProject.file("keystore.properties")

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
Expand All @@ -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")
}
}
}
}
Expand All @@ -75,7 +79,9 @@ android {
release {
isMinifyEnabled = false

signingConfig = signingConfigs.getByName("release")
if (keystorePropertiesFile.canRead()) {
signingConfig = signingConfigs.getByName("release")
}
}

debug {
Expand All @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.

0 comments on commit aa12b4b

Please sign in to comment.