diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b726df2..b655b29 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -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 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e11c884..9182cdc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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) diff --git a/app/manifest.json b/app/manifest.json deleted file mode 100644 index 5da264e..0000000 --- a/app/manifest.json +++ /dev/null @@ -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" -} \ No newline at end of file diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/KarooHeadwindExtension.kt b/app/src/main/kotlin/de/timklge/karooheadwind/KarooHeadwindExtension.kt index 64dbe8d..97629a6 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/KarooHeadwindExtension.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/KarooHeadwindExtension.kt @@ -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" }