Skip to content

Commit

Permalink
Merge pull request #28 from boschglobal/feature-27
Browse files Browse the repository at this point in the history
feature: Add staging signing config
  • Loading branch information
SebastianSchildt authored Dec 1, 2023
2 parents f05190b + 0d450f3 commit a88bafb
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 70 deletions.
13 changes: 13 additions & 0 deletions .github/actions/setup-project/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: setup_project
description: Setups the gradle and java environment

runs:
using: "composite"
steps:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
49 changes: 49 additions & 0 deletions .github/workflows/build-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build_main

on:
push:
branches:
- testdeploy

env:
GPR_USERNAME: ${{ github.actor }}
GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
validate-project:
uses: ./.github/workflows/reusable-build-validation.yaml

deploy-artifacts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-project

- name: Decode Keystore
uses: timheuer/base64-to-file@v1
with:
fileName: 'keystore.jks'
encodedString: ${{ secrets.KEYSTORE_RELEASE }}

- name: Assemble release artifacts
env:
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
run: ./gradlew assembleRelease

- name: Archive .apk file
uses: actions/upload-artifact@v3
with:
name: kuksa_companion_app.apk
path: app/build/outputs/apk/release/app-release.apk
if-no-files-found: error
retention-days: 14

- name: Archive changelog
uses: actions/upload-artifact@v3
with:
name: CHANGELOG.md
path: CHANGELOG.md
retention-days: 14
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ on:

jobs:
build-project:
uses: ./.github/workflows/reusable_build_validation.yaml
uses: ./.github/workflows/reusable-build-validation.yaml
26 changes: 0 additions & 26 deletions .github/workflows/build_main.yaml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@ jobs:

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- uses: ./.github/actions/setup-project

- name: Set Release Version
run: ./gradlew setReleaseVersion # Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command
Expand All @@ -36,7 +29,7 @@ jobs:
run: ./gradlew assembleRelease

- name: Rename release artefact
run: mv app/build/outputs/apk/release/app-release-unsigned.apk kuksa_companion_app.apk
run: mv app/build/outputs/apk/release/app-release.apk kuksa_companion_app.apk

- name: Publish Release
uses: softprops/action-gh-release@v1
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/reusable-build-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: build_validation

on:
workflow_call:

jobs:
build-project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Project
uses: ./.github/actions/setup-project

- name: Run 'check' with Gradle Wrapper
run: ./gradlew ktlintCheck detekt

# - name: Run 'test' with Gradle Wrapper
# run: ./gradlew test
32 changes: 0 additions & 32 deletions .github/workflows/reusable_build_validation.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ captures/
*.apk
output.json
stdout
app/release/

# IntelliJ
*.iml
Expand Down
31 changes: 31 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
*/

import org.eclipse.kuksa.companion.property.PropertiesLoader

plugins {
id("com.android.application")
id("com.google.devtools.ksp")
Expand All @@ -40,14 +42,43 @@ android {
useSupportLibrary = true
}
}
signingConfigs {
create("release") {
val localProperties = PropertiesLoader().load("$rootDir/local.properties")

val runnerTempPath = System.getenv("RUNNER_TEMP") ?: System.getProperty("user.home")
val runnerKeystoreFilePath = "$runnerTempPath/keystore.jks"
val runnerKeystoreFile = File(runnerKeystoreFilePath)
val keystoreFile = if (runnerKeystoreFile.exists()) {
runnerKeystoreFile
} else { // For building locally - Just add the keys to the local.properties
println("No keystore property file found - looking for a local one")
val propertyKeystorePath = localProperties?.getProperty("release.keystore.path") ?: return@create
File("$runnerTempPath/$propertyKeystorePath")
}

storeFile = keystoreFile
keyAlias = System.getenv("SIGNING_KEY_ALIAS")
?: localProperties?.getProperty("release.keystore.key.alias")
keyPassword = System.getenv("SIGNING_KEY_PASSWORD")
?: localProperties?.getProperty("release.keystore.key.password")
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
?: localProperties?.getProperty("release.keystore.store.password")
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("release")
}
// For store releases like F-Droid where an unsigned artifact is needed
create("unsigned") {
initWith(getByName("release"))
applicationIdSuffix = ".unsigned"
}
}
compileOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

package org.eclipse.kuksa.companion.property

import java.io.File
import java.util.Properties

class PropertiesLoader {
fun load(path: String): Properties? {
val properties = File(path)
if (!properties.exists()) return null

properties.reader().use { reader ->
return Properties().apply {
load(reader)
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kuksaSdk = "0.1.2-SNAPSHOT"
lifecycleRuntimeCompose = "2.6.2"
ramsesAar = "1.1.0"
navigationCompose = "2.7.5"
kotlinxSerializationJson = "1.6.0"
kotlinxSerializationJson = "1.6.1"
constraintlayoutCompose = "1.0.1"
kotlinSerializationPlugin = "1.9.20"
devtoolsKsp = "1.9.20-1.0.14"
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dependencyResolutionManagement {

include(":app")

// Needs to be redundant with buildSrc because the settings.gradle is compiled before the buildSrc folder
fun loadLocalProperties(): Properties? {
val localProperties = file("$rootDir/local.properties")
if (!localProperties.exists()) return null
Expand Down

0 comments on commit a88bafb

Please sign in to comment.