From f086e786d92f704df71faad8370493dda360a629 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Fri, 8 Dec 2023 08:58:51 +0100 Subject: [PATCH 1/5] feature: Provide Signed .apk for TestApp Closes: #64 Signed-off-by: Andre Weber --- .github/workflows/build-main.yaml | 50 +++++++++++++++++++ app/build.gradle.kts | 24 +++++++++ .../kuksa/property/PropertiesLoader.kt | 35 +++++++++++++ 3 files changed, 109 insertions(+) create mode 100755 .github/workflows/build-main.yaml create mode 100644 buildSrc/src/main/kotlin/org/eclipse/kuksa/property/PropertiesLoader.kt diff --git a/.github/workflows/build-main.yaml b/.github/workflows/build-main.yaml new file mode 100755 index 00000000..d156b2b1 --- /dev/null +++ b/.github/workflows/build-main.yaml @@ -0,0 +1,50 @@ +name: Build Main + +on: + push: + branches: + - main + +jobs: + build-project: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Update Version + run: npm run bump-release # Updates the semantic version depending on the last commits e.g. feature / bugfix + + - name: Set Snapshot Version + run: ./gradlew setSnapshotVersion # Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command + + - name: Build SDK TestApp + uses: eclipse-kuksa/kuksa-android-companion/.github/actions/create-release-apk + with: + keystore: ${{ secrets.KEYSTORE_DEBUG }} + key_alias: ${{ secrets.SIGNING_KEY_ALIAS }} + key_password: ${{ secrets.SIGNING_KEY_PASSWORD }} + store_password: ${{ secrets.SIGNING_STORE_PASSWORD }} + + - name: Archive .apk file + uses: actions/upload-artifact@v3 + with: + name: kuksa_sdk_testapp.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 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 902f0a52..1889a5b8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import org.eclipse.kuksa.property.PropertiesLoader + /* * Copyright (c) 2023 Contributors to the Eclipse Foundation * @@ -59,6 +61,24 @@ android { useSupportLibrary = true } } + signingConfigs { + create("release") { + val propertiesLoader = PropertiesLoader() + val localProperties = propertiesLoader.load("$rootDir/local.properties") + + val keystorePath = System.getenv("KEYSTORE_PATH") ?: localProperties?.getProperty("release.keystore.path") + println("Defined keystore path: $keystorePath") + if (keystorePath == null) return@create + + storeFile = File(keystorePath) + 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 { // for local builds, used to find shrinking issues val isMinify = project.hasProperty("minify") @@ -75,6 +95,10 @@ android { ) } } + + release { + signingConfig = signingConfigs.getByName("release") + } } namespace = "org.eclipse.kuksa.testapp" lint { diff --git a/buildSrc/src/main/kotlin/org/eclipse/kuksa/property/PropertiesLoader.kt b/buildSrc/src/main/kotlin/org/eclipse/kuksa/property/PropertiesLoader.kt new file mode 100644 index 00000000..2977c84f --- /dev/null +++ b/buildSrc/src/main/kotlin/org/eclipse/kuksa/property/PropertiesLoader.kt @@ -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.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) + } + } + } +} From 731c81c63594cb1dc618a3636568d09b75c884b0 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Fri, 8 Dec 2023 09:05:12 +0100 Subject: [PATCH 2/5] chore: Align Workflow Names --- .github/workflows/{build.yaml => build-pull-request.yaml} | 3 +-- .../workflows/{check_license.yaml => check-license.yaml} | 3 +-- .github/workflows/commitlint.yaml | 3 +-- .github/workflows/dash.yaml | 3 +-- .github/workflows/deploy-release.yaml | 2 +- .github/workflows/deploy-snapshot.yaml | 6 +++--- 6 files changed, 8 insertions(+), 12 deletions(-) rename .github/workflows/{build.yaml => build-pull-request.yaml} (98%) rename .github/workflows/{check_license.yaml => check-license.yaml} (96%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build-pull-request.yaml similarity index 98% rename from .github/workflows/build.yaml rename to .github/workflows/build-pull-request.yaml index 3b2f9429..57269ffc 100755 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build-pull-request.yaml @@ -1,4 +1,4 @@ -name: build +name: Validate Pull Request on: pull_request @@ -7,7 +7,6 @@ jobs: build-project: runs-on: ubuntu-latest steps: - - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/check_license.yaml b/.github/workflows/check-license.yaml similarity index 96% rename from .github/workflows/check_license.yaml rename to .github/workflows/check-license.yaml index f400b608..1c73a27f 100755 --- a/.github/workflows/check_license.yaml +++ b/.github/workflows/check-license.yaml @@ -1,4 +1,4 @@ -name: spdx +name: SPDX License Check on: pull_request @@ -7,7 +7,6 @@ jobs: check-spdx-headers: runs-on: ubuntu-latest steps: - - name: Checkout code uses: actions/checkout@v3 with: diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml index ad770fd3..ed49d02a 100644 --- a/.github/workflows/commitlint.yaml +++ b/.github/workflows/commitlint.yaml @@ -1,4 +1,4 @@ -name: commitlint +name: Commitlint on: pull_request @@ -7,7 +7,6 @@ jobs: commitlint: runs-on: ubuntu-latest steps: - - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/dash.yaml b/.github/workflows/dash.yaml index a74fb554..d91fe56e 100644 --- a/.github/workflows/dash.yaml +++ b/.github/workflows/dash.yaml @@ -1,4 +1,4 @@ -name: dash +name: Dash License Check on: pull_request @@ -7,7 +7,6 @@ jobs: check-dash: runs-on: ubuntu-latest steps: - - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/deploy-release.yaml b/.github/workflows/deploy-release.yaml index 55ac14bc..3835b79a 100644 --- a/.github/workflows/deploy-release.yaml +++ b/.github/workflows/deploy-release.yaml @@ -1,4 +1,4 @@ -name: deploy-release +name: Deploy Release SDK concurrency: production diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml index 3a22f627..1f71507c 100644 --- a/.github/workflows/deploy-snapshot.yaml +++ b/.github/workflows/deploy-snapshot.yaml @@ -1,6 +1,6 @@ -name: deploy-snapshot +name: Deploy Snapshot SDK -concurrency: production +concurrency: snapshot on: push: @@ -36,4 +36,4 @@ jobs: ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }} ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }} ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }} - run: ./gradlew --stacktrace publishAllPublicationsToOSSRHSnapshotRepository + run: ./gradlew publishAllPublicationsToOSSRHSnapshotRepository From 514a3a56241cd099e3ada052933916b5b561a50c Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Fri, 8 Dec 2023 09:09:36 +0100 Subject: [PATCH 3/5] chore: Add Reusable 'Setup Project'-Action --- .github/actions/setup-project/action.yaml | 13 +++++++++++++ .github/workflows/build-main.yaml | 9 ++------- .github/workflows/build-pull-request.yaml | 9 ++------- .github/workflows/dash.yaml | 9 ++------- .github/workflows/deploy-release.yaml | 9 ++------- .github/workflows/deploy-snapshot.yaml | 9 ++------- 6 files changed, 23 insertions(+), 35 deletions(-) create mode 100644 .github/actions/setup-project/action.yaml diff --git a/.github/actions/setup-project/action.yaml b/.github/actions/setup-project/action.yaml new file mode 100644 index 00000000..6eae6c99 --- /dev/null +++ b/.github/actions/setup-project/action.yaml @@ -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 diff --git a/.github/workflows/build-main.yaml b/.github/workflows/build-main.yaml index d156b2b1..74a28053 100755 --- a/.github/workflows/build-main.yaml +++ b/.github/workflows/build-main.yaml @@ -12,13 +12,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup Project + uses: ./.github/actions/setup-project - name: Update Version run: npm run bump-release # Updates the semantic version depending on the last commits e.g. feature / bugfix diff --git a/.github/workflows/build-pull-request.yaml b/.github/workflows/build-pull-request.yaml index 57269ffc..8bdb8ed9 100755 --- a/.github/workflows/build-pull-request.yaml +++ b/.github/workflows/build-pull-request.yaml @@ -13,13 +13,8 @@ jobs: - name: "Run Docker Container of Databroker in detached mode" run: docker run --pull=always --rm --publish 55556:55556/tcp --detach --name databroker ghcr.io/eclipse/kuksa.val/databroker:master --port 55556 --insecure - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup Project + uses: ./.github/actions/setup-project - name: Run 'assemble' with Gradle Wrapper run: ./gradlew assemble diff --git a/.github/workflows/dash.yaml b/.github/workflows/dash.yaml index d91fe56e..50ab90d2 100644 --- a/.github/workflows/dash.yaml +++ b/.github/workflows/dash.yaml @@ -10,13 +10,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup Project + uses: ./.github/actions/setup-project - name: Create Dash Dependency Report run: ./gradlew mergeDashFiles diff --git a/.github/workflows/deploy-release.yaml b/.github/workflows/deploy-release.yaml index 3835b79a..67b65a0a 100644 --- a/.github/workflows/deploy-release.yaml +++ b/.github/workflows/deploy-release.yaml @@ -15,13 +15,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup Project + 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 diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml index 1f71507c..cc180e07 100644 --- a/.github/workflows/deploy-snapshot.yaml +++ b/.github/workflows/deploy-snapshot.yaml @@ -15,13 +15,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup Project + uses: ./.github/actions/setup-project - name: Update Version run: npm run bump-release # Updates the semantic version depending on the last commits e.g. feature / bugfix From ce99b35d0d3d592a27e24956409cac5c0741f2ca Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Fri, 8 Dec 2023 10:24:58 +0100 Subject: [PATCH 4/5] chore: Add Reusable 'Create Release Apk'-Action --- .github/actions/create-release-apk/action.yml | 38 +++++++++++++++++++ .github/workflows/build-main.yaml | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/actions/create-release-apk/action.yml diff --git a/.github/actions/create-release-apk/action.yml b/.github/actions/create-release-apk/action.yml new file mode 100644 index 00000000..0cfff92d --- /dev/null +++ b/.github/actions/create-release-apk/action.yml @@ -0,0 +1,38 @@ +name: Release apk +description: Decodes any provided Keystore and creates a signed .apk with this. + +inputs: + keystore: + description: "Keystore Base64 encoded" + required: true + key_alias: + description: "Keystore alias" + required: true + key_password: + description: "Keystore password" + required: true + store_password: + description: "Store password" + required: true + gradle_task: + description: "Gradle Task to execute" + required: false + default: assembleRelease + +runs: + using: "composite" + steps: + - name: Decode Keystore + uses: timheuer/base64-to-file@v1 + with: + fileName: 'keystore.jks' + encodedString: ${{ inputs.keystore }} + + - name: Create .apk file + env: + SIGNING_KEY_ALIAS: ${{ inputs.key_alias }} + SIGNING_KEY_PASSWORD: ${{ inputs.key_password }} + SIGNING_STORE_PASSWORD: ${{ inputs.store_password }} + KEYSTORE_PATH: ${{ runner.temp }}/keystore.jks + shell: bash + run: ./gradlew ${{ inputs.gradle_task }} diff --git a/.github/workflows/build-main.yaml b/.github/workflows/build-main.yaml index 74a28053..684111ce 100755 --- a/.github/workflows/build-main.yaml +++ b/.github/workflows/build-main.yaml @@ -22,12 +22,13 @@ jobs: run: ./gradlew setSnapshotVersion # Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command - name: Build SDK TestApp - uses: eclipse-kuksa/kuksa-android-companion/.github/actions/create-release-apk + uses: ./.github/actions/create-release-apk with: keystore: ${{ secrets.KEYSTORE_DEBUG }} key_alias: ${{ secrets.SIGNING_KEY_ALIAS }} key_password: ${{ secrets.SIGNING_KEY_PASSWORD }} store_password: ${{ secrets.SIGNING_STORE_PASSWORD }} + gradle_task: app:assembleRelease - name: Archive .apk file uses: actions/upload-artifact@v3 From 3bcd066dab933e6b7d2f755021df07226e7cadbd Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Fri, 8 Dec 2023 11:21:16 +0100 Subject: [PATCH 5/5] chore: Use 'assembleDebug' in PR Pipeline --- .github/workflows/build-pull-request.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-pull-request.yaml b/.github/workflows/build-pull-request.yaml index 8bdb8ed9..907f2019 100755 --- a/.github/workflows/build-pull-request.yaml +++ b/.github/workflows/build-pull-request.yaml @@ -16,8 +16,8 @@ jobs: - name: Setup Project uses: ./.github/actions/setup-project - - name: Run 'assemble' with Gradle Wrapper - run: ./gradlew assemble + - name: Run 'assembleDebug' with Gradle Wrapper + run: ./gradlew assembleDebug - name: Run 'lint' with Gradle Wrapper run: ./gradlew ktlintCheck detekt