fail on sonaRelease if the version is SNAPSHOT

This commit is contained in:
Eugene Yokota 2025-05-21 00:26:51 -04:00
parent 8a7d84aa08
commit 9e7a0fa136
1 changed files with 16 additions and 8 deletions

View File

@ -40,14 +40,22 @@ object Publishing {
val extracted = Project.extract(s0) val extracted = Project.extract(s0)
val log = extracted.get(Keys.sLog) val log = extracted.get(Keys.sLog)
val dn = extracted.get(Keys.sonaDeploymentName) val dn = extracted.get(Keys.sonaDeploymentName)
val (s1, bundle) = extracted.runTask(Keys.sonaBundle, s0) val v = extracted.get(Keys.version)
val (s2, creds) = extracted.runTask(Keys.credentials, s1) if (v.endsWith("-SNAPSHOT")) {
val client = fromCreds(creds) log.error("""SNAPSHOTs are not supported on the Central Portal;
try { configure ThisBuild / publishTo to publish directly to the central-snapshots.
client.uploadBundle(bundle.toPath(), dn, pt, log) see https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html for details.""")
s2 s0.fail
} finally { } else {
client.close() val (s1, bundle) = extracted.runTask(Keys.sonaBundle, s0)
val (s2, creds) = extracted.runTask(Keys.credentials, s1)
val client = fromCreds(creds)
try {
client.uploadBundle(bundle.toPath(), dn, pt, log)
s2
} finally {
client.close()
}
} }
} }