Add build pipeline

This commit is contained in:
Tim Kluge 2024-12-16 22:34:21 +01:00
parent d023f7f19a
commit 7a41ebbb3e
5 changed files with 85 additions and 4 deletions

55
.github/workflows/android.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Build
on:
workflow_dispatch:
push:
branches: [ "master" ]
tags: [ "*" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set up environment variables
run: |
echo "GPR_USER=${{ github.actor }}" >> $GITHUB_ENV
echo "GPR_KEY=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> $GITHUB_ENV
echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV
echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV
echo "KEYSTORE_BASE64=${{ secrets.KEYSTORE_BASE64 }}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
# - name: Archive APK
# uses: actions/upload-artifact@v4
# with:
# name: app-release.apk
# path: app/build/outputs/apk/release/app-release.apk
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ github.ref_name }}
prerelease: false
generateReleaseNotes: true
artifacts: app/build/outputs/apk/release/app-release.apk, app/manifest.json, app/karoo-headwind.png
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,5 +1,9 @@
# Karoo Headwind Extension
[![Build](https://github.com/timklge/karoo-headwind/actions/workflows/android.yml/badge.svg)](https://github.com/timklge/karoo-headwind/actions/workflows/android.yml)
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/timklge/karoo-headwind/total)
![GitHub License](https://img.shields.io/github/license/timklge/karoo-headwind)
This extension for Karoo devices adds a graphical data field that shows the current headwind direction and speed relative to the riding direction.
Compatible with Karoo 2 and Karoo 3 devices.

View File

@ -1,3 +1,5 @@
import java.util.Base64
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
@ -17,9 +19,26 @@ android {
versionName = "1.0.0-beta2"
}
signingConfigs {
create("release") {
val env: MutableMap<String, String> = System.getenv()
keyAlias = env["KEY_ALIAS"]
keyPassword = env["KEY_PASSWORD"]
val base64keystore: String = env["KEYSTORE_BASE64"] ?: ""
val keystoreFile: File = File.createTempFile("keystore", ".jks")
keystoreFile.writeBytes(Base64.getDecoder().decode(base64keystore))
storeFile = keystoreFile
storePassword = env["KEYSTORE_PASSWORD"]
}
}
buildTypes {
release {
debug {
isMinifyEnabled = false
}
release {
signingConfig = signingConfigs.getByName("release")
// isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

View File

@ -208,7 +208,7 @@ fun KarooSystemService.getHeadingFlow(): Flow<Double> {
.mapNotNull { (it as? StreamState.Streaming)?.dataPoint?.values }
.map { values ->
val heading = values[DataType.Field.LOC_BEARING]
Log.d(KarooHeadwindExtension.TAG, "Updated gps bearing: $heading")
heading ?: 0.0
}
.distinctUntilChanged()

View File

@ -16,8 +16,11 @@ pluginManagement {
mavenCentral()
}
}
val gprUser = getLocalProperty("gpr.user")
val gprKey = getLocalProperty("gpr.key")
val env: MutableMap<String, String> = System.getenv()
val gprUser = if(env.containsKey("GPR_USER")) env["GPR_USER"] else getLocalProperty("gpr.user")
val gprKey = if(env.containsKey("GPR_KEY")) env["GPR_KEY"] else getLocalProperty("gpr.key")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {