build: drive all module versions from the catalog

Make every module read its release version from gradle/libs.versions.toml
instead of carrying its own literal, so a release bump is a single-file edit.

- Move the Android versionCode out of amethyst/build.gradle.kts into the
  catalog as `appCode`; amethyst reads it via libs.versions.appCode.get().
- quartz publishes with version = libs.versions.app.get().
- geode generates a BuildConfig.VERSION from the catalog (new
  generateVersionFile task) and RelayInfo.VERSION reads it, so the NIP-11
  software version tracks releases.
- Update the root build comment to point at the appCode entry.

Version-neutral: everything still resolves to the current 1.12.0 / 448.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vitor Pamplona
2026-06-17 11:19:52 -04:00
co-authored by Claude Opus 4.8
parent af27b7750e
commit 270d229d0a
6 changed files with 39 additions and 8 deletions
+4 -1
View File
@@ -76,7 +76,10 @@ android {
libs.versions.android.targetSdk libs.versions.android.targetSdk
.get() .get()
.toInt() .toInt()
versionCode = 448 versionCode =
libs.versions.appCode
.get()
.toInt()
versionName = generateVersionName(libs.versions.app.get(), rootDir) versionName = generateVersionName(libs.versions.app.get(), rootDir)
buildConfigField("String", "RELEASE_NOTES_ID", "\"40e817712e397c07ba31784a92fa474aa095896a828c0e2dea0d09c60d49ee1e\"") buildConfigField("String", "RELEASE_NOTES_ID", "\"40e817712e397c07ba31784a92fa474aa095896a828c0e2dea0d09c60d49ee1e\"")
+1 -1
View File
@@ -16,7 +16,7 @@ plugins {
} }
// Shared app version for all subprojects — read from gradle/libs.versions.toml. // 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. // Desktop packageVersion inherits via project.version in desktopApp/build.gradle.kts.
val appVersion = libs.versions.app.get() val appVersion = libs.versions.app.get()
+25
View File
@@ -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 { sourceSets {
main { main {
kotlin.srcDir("src/main/kotlin") kotlin.srcDir("src/main/kotlin")
kotlin.srcDir(generateVersionFile)
} }
test { test {
kotlin.srcDir("src/test/kotlin") kotlin.srcDir("src/test/kotlin")
@@ -38,10 +38,10 @@ data class RelayInfo(
val json: String by lazy { JsonMapper.toJson(document) } val json: String by lazy { JsonMapper.toJson(document) }
companion object { companion object {
const val NAME = "geode" const val NAME = "Geode"
const val DESCRIPTION = "Embedded Nostr relay from the Amethyst quartz library." const val DESCRIPTION = "Nostr relay from Amethyst"
const val SOFTWARE = "https://github.com/vitorpamplona/amethyst/tree/main/geode" 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 * NIPs this relay implements out of the box. Single source of
+3 -2
View File
@@ -1,8 +1,9 @@
[versions] [versions]
# Amethyst app version — single source of truth consumed by both Android (amethyst/) # Amethyst app version — single source of truth consumed by both Android (amethyst/)
# and Desktop (desktopApp/). Android versionCode is bumped independently in # and Desktop (desktopApp/). `appCode` is the Android versionCode: a monotonic
# amethyst/build.gradle because it must be a monotonic integer. # integer that must increment on every release, even when `app` is unchanged.
app = "1.12.0" app = "1.12.0"
appCode = "448"
accompanistAdaptive = "0.37.3" accompanistAdaptive = "0.37.3"
cachemapVersion = "0.2.4" cachemapVersion = "0.2.4"
composeMultiplatform = "1.11.1" composeMultiplatform = "1.11.1"
+3 -1
View File
@@ -449,7 +449,9 @@ mavenPublishing {
coordinates( coordinates(
groupId = "com.vitorpamplona.quartz", groupId = "com.vitorpamplona.quartz",
artifactId = "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 // Configure publishing to Maven Central