Generate manifest as part of gradle build (#64)

This commit is contained in:
timklge 2025-03-06 23:26:29 +01:00 committed by GitHub
parent 245243eedd
commit 3a4515268e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 20 deletions

View File

@ -14,6 +14,9 @@ jobs:
permissions:
contents: write
steps:
- name: Extract tag name
if: startsWith(github.ref, 'refs/tags/')
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Set up environment variables
run: |
echo "GPR_USER=${{ github.actor }}" >> $GITHUB_ENV
@ -22,7 +25,7 @@ jobs:
echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV
echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV
echo "KEYSTORE_BASE64=${{ secrets.KEYSTORE_BASE64 }}" >> $GITHUB_ENV
echo "BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
@ -36,11 +39,11 @@ jobs:
- 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: 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

View File

@ -15,8 +15,8 @@ android {
applicationId = "de.timklge.karooheadwind"
minSdk = 26
targetSdk = 35
versionCode = 15
versionName = "1.3.1"
versionCode = 100 + (System.getenv("BUILD_NUMBER")?.toInt() ?: 1)
versionName = System.getenv("RELEASE_VERSION") ?: "1.0"
}
signingConfigs {
@ -51,9 +51,40 @@ android {
}
buildFeatures {
compose = true
buildConfig = true
}
}
tasks.register("generateManifest") {
description = "Generates manifest.json with current version information"
group = "build"
doLast {
val manifestFile = file("$projectDir/manifest.json")
val manifest = mapOf(
"label" to "karoo-headwind",
"packageName" to "de.timklge.karooheadwind",
"iconUrl" to "https://github.com/timklge/karoo-headwind/releases/latest/download/karoo-headwind.png",
"latestApkUrl" to "https://github.com/timklge/karoo-headwind/releases/latest/download/app-release.apk",
"latestVersion" to android.defaultConfig.versionName,
"latestVersionCode" to android.defaultConfig.versionCode,
"developer" to "timklge",
"description" to "Provides headwind direction, wind speed and other weather data fields.",
"releaseNotes" to "* Show current weather in app menu\n" +
"* Add individual forecast fields\n" +
"* Fix distance update in route forecast"
)
val gson = groovy.json.JsonBuilder(manifest).toPrettyString()
manifestFile.writeText(gson)
println("Generated manifest.json with version ${android.defaultConfig.versionName} (${android.defaultConfig.versionCode})")
}
}
tasks.named("assemble") {
dependsOn("generateManifest")
}
dependencies {
implementation(libs.mapbox.sdk.turf)
implementation(libs.hammerhead.karoo.ext)

View File

@ -1,11 +0,0 @@
{
"label": "karoo-headwind",
"packageName": "de.timklge.karooheadwind",
"iconUrl": "https://github.com/timklge/karoo-headwind/releases/latest/download/karoo-headwind.png",
"latestApkUrl": "https://github.com/timklge/karoo-headwind/releases/latest/download/app-release.apk",
"latestVersion": "1.3.1",
"latestVersionCode": 15,
"developer": "timklge",
"description": "Provides headwind direction, wind speed and other weather data fields",
"releaseNotes": "* Add individual forecast fields\n* Fix forecast along route distance update"
}

View File

@ -54,7 +54,7 @@ import kotlin.math.roundToInt
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.minutes
class KarooHeadwindExtension : KarooExtension("karoo-headwind", "1.3.1") {
class KarooHeadwindExtension : KarooExtension("karoo-headwind", BuildConfig.VERSION_NAME) {
companion object {
const val TAG = "karoo-headwind"
}