11import java .io .FileInputStream
22import java .util .Properties
33import sbt .ThisBuild
4+ import scala .sys .process .Process
5+ import xerial .sbt .Sonatype .sonatypeCentralHost
46
57val scala3Version = " 3.3.7"
68val scala2Version = " 2.13.18"
@@ -15,6 +17,9 @@ inThisBuild(
1517 Seq (
1618 organization := " org.funfix" ,
1719 scalaVersion := scala2Version,
20+ // Configure for Sonatype Central Portal
21+ sonatypeCredentialHost := sonatypeCentralHost,
22+ usePgpKeyHex(sys.env.get(" PGP_KEY_ID" ).getOrElse(" " )),
1823 // ---
1924 // Settings for dealing with the local Gradle-assembled artifacts
2025 // Also see: publishLocalGradleDependencies
@@ -35,7 +40,8 @@ inThisBuild(
3540 .orElse(Option (System .getProperty(" buildRelease" )))
3641 .exists(it => it == " true" || it == " 1" || it == " yes" || it == " on" )
3742 if (isRelease) base else s " $base-SNAPSHOT "
38- }
43+ },
44+ versionScheme := Some (" early-semver" )
3945 )
4046)
4147
@@ -101,7 +107,7 @@ val sharedSettings = Seq(
101107 publishTo := {
102108 val centralSnapshots = " https://central.sonatype.com/repository/maven-snapshots/"
103109 if (version.value.endsWith(" -SNAPSHOT" )) Some (" central-snapshots" .at(centralSnapshots))
104- else localStaging .value
110+ else sonatypePublishToBundle .value
105111 },
106112
107113 // ScalaDoc settings
@@ -130,10 +136,14 @@ lazy val root = project
130136 publishLocalGradleDependencies := {
131137 import scala .sys .process .*
132138 val rootDir = (ThisBuild / baseDirectory).value
133- val command = Process (
134- " ./gradlew" :: " publishToMavenLocal" :: Nil ,
135- rootDir
136- )
139+ val commandArgs =
140+ List (
141+ List (" ./gradlew" ),
142+ if (! version.value.endsWith(" -SNAPSHOT" )) List (" -PbuildRelease=true" ) else Nil ,
143+ List (" publishToMavenLocal" )
144+ ).flatten
145+
146+ val command = Process (commandArgs, rootDir)
137147 val log = streams.value.log
138148 val exitCode = command ! log
139149 if (exitCode != 0 ) {
@@ -174,5 +184,5 @@ addCommandAlias(
174184)
175185addCommandAlias(
176186 " ci-publish" ,
177- " ;publishLocalGradleDependencies; +Test/compile; +publishSigned; sonaUpload "
187+ " ;publishLocalGradleDependencies; +Test/compile; +publishSigned; sonatypeBundleUpload "
178188)
0 commit comments