diff --git a/amethyst/build.gradle.kts b/amethyst/build.gradle.kts index a55d77093a..c44598b810 100644 --- a/amethyst/build.gradle.kts +++ b/amethyst/build.gradle.kts @@ -76,7 +76,10 @@ android { libs.versions.android.targetSdk .get() .toInt() - versionCode = 448 + versionCode = + libs.versions.appCode + .get() + .toInt() versionName = generateVersionName(libs.versions.app.get(), rootDir) buildConfigField("String", "RELEASE_NOTES_ID", "\"40e817712e397c07ba31784a92fa474aa095896a828c0e2dea0d09c60d49ee1e\"") diff --git a/build.gradle.kts b/build.gradle.kts index 4ffcd6c263..3a9b1df6dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { } // Shared app version for all subprojects — read from gradle/libs.versions.toml. -// Android versionCode stays local in amethyst/build.gradle.kts (must be monotonic int). +// Android versionCode is the `appCode` entry in the same catalog (must be monotonic int). // Desktop packageVersion inherits via project.version in desktopApp/build.gradle.kts. val appVersion = libs.versions.app.get() diff --git a/geode/build.gradle.kts b/geode/build.gradle.kts index 5b4ea35fa9..bc41967f3d 100644 --- a/geode/build.gradle.kts +++ b/geode/build.gradle.kts @@ -19,9 +19,34 @@ kotlin { } } +// Generate a BuildConfig.kt carrying the app version from the catalog so +// RelayInfo.VERSION (reported over NIP-11) tracks releases automatically +// instead of being a hand-bumped literal. +val generateVersionFile by tasks.registering { + val versionValue = libs.versions.app.get() + val outDir = layout.buildDirectory.dir("generated/version/kotlin") + inputs.property("version", versionValue) + outputs.dir(outDir) + doLast { + val file = outDir.get().file("com/vitorpamplona/geode/BuildConfig.kt").asFile + file.parentFile.mkdirs() + file.writeText( + buildString { + appendLine("// Generated by the :geode build — do not edit.") + appendLine("package com.vitorpamplona.geode") + appendLine() + appendLine("internal object BuildConfig {") + appendLine(" const val VERSION = \"$versionValue\"") + appendLine("}") + }, + ) + } +} + sourceSets { main { kotlin.srcDir("src/main/kotlin") + kotlin.srcDir(generateVersionFile) } test { kotlin.srcDir("src/test/kotlin") diff --git a/geode/src/main/kotlin/com/vitorpamplona/geode/RelayInfo.kt b/geode/src/main/kotlin/com/vitorpamplona/geode/RelayInfo.kt index 5ee2e5d772..5cde5a1989 100644 --- a/geode/src/main/kotlin/com/vitorpamplona/geode/RelayInfo.kt +++ b/geode/src/main/kotlin/com/vitorpamplona/geode/RelayInfo.kt @@ -38,10 +38,10 @@ data class RelayInfo( val json: String by lazy { JsonMapper.toJson(document) } companion object { - const val NAME = "geode" - const val DESCRIPTION = "Embedded Nostr relay from the Amethyst quartz library." + const val NAME = "Geode" + const val DESCRIPTION = "Nostr relay from Amethyst" const val SOFTWARE = "https://github.com/vitorpamplona/amethyst/tree/main/geode" - const val VERSION = "1.12.0" + const val VERSION = BuildConfig.VERSION /** * NIPs this relay implements out of the box. Single source of diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e7bfa05d5..225e6b1583 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,9 @@ [versions] # Amethyst app version — single source of truth consumed by both Android (amethyst/) -# and Desktop (desktopApp/). Android versionCode is bumped independently in -# amethyst/build.gradle because it must be a monotonic integer. +# and Desktop (desktopApp/). `appCode` is the Android versionCode: a monotonic +# integer that must increment on every release, even when `app` is unchanged. app = "1.12.0" +appCode = "448" accompanistAdaptive = "0.37.3" cachemapVersion = "0.2.4" composeMultiplatform = "1.11.1" diff --git a/quartz/build.gradle.kts b/quartz/build.gradle.kts index cb70a4f5df..918277dc5a 100644 --- a/quartz/build.gradle.kts +++ b/quartz/build.gradle.kts @@ -449,7 +449,9 @@ mavenPublishing { coordinates( groupId = "com.vitorpamplona.quartz", artifactId = "quartz", - version = "1.12.0", + // Library version tracks the app version in gradle/libs.versions.toml, + // bumped in lockstep with each release. + version = libs.versions.app.get(), ) // Configure publishing to Maven Central