SemVer plugin updated.
This commit is contained in:
		
							parent
							
								
									127754c2a2
								
							
						
					
					
						commit
						46b7ae52c8
					
				
					 2 changed files with 16 additions and 74 deletions
				
			
		
							
								
								
									
										80
									
								
								build.sbt
									
										
									
									
									
								
							
							
						
						
									
										80
									
								
								build.sbt
									
										
									
									
									
								
							|  | @ -4,81 +4,14 @@ ThisBuild / organizationName     := "garrity software" | |||
| ThisBuild / organization         := "gs" | ||||
| ThisBuild / organizationHomepage := Some(url("https://garrity.co/")) | ||||
| ThisBuild / scalaVersion         := scala3 | ||||
| ThisBuild / versionScheme        := Some("early-semver") | ||||
| 
 | ||||
| externalResolvers := Seq( | ||||
|   "Garrity Software Releases" at "https://maven.garrity.co/releases" | ||||
| ) | ||||
| ThisBuild / versionScheme        := Some("semver-spec") | ||||
| 
 | ||||
| val ProjectName: String = "gs-config" | ||||
| val Description: String = "Garrity Software Configuration Library" | ||||
| 
 | ||||
| /** Helper to extract the value from `-Dproperty=value`. | ||||
|   * | ||||
|   * @param name | ||||
|   *   The property name. | ||||
|   * @param conv | ||||
|   *   The conversion function to the output type. | ||||
|   * @return | ||||
|   *   The converted value, or `None` if no value exists. | ||||
|   */ | ||||
| def getProperty[A]( | ||||
|   name: String, | ||||
|   conv: String => A | ||||
| ): Option[A] = | ||||
|   Option(System.getProperty(name)).map(conv) | ||||
| 
 | ||||
| /** Use `sbt -Dversion=<version>` to provide the version, minus the SNAPSHOT | ||||
|   * modifier. This is the typical approach for producing releases. | ||||
|   */ | ||||
| val VersionProperty: String = "version" | ||||
| 
 | ||||
| /** Use `sbt -Drelease=true` to trigger a release build. | ||||
|   */ | ||||
| val ReleaseProperty: String = "release" | ||||
| 
 | ||||
| /** The value of `-Dversion=<value>`. | ||||
|   * | ||||
|   * @return | ||||
|   *   The version passed as input to SBT. | ||||
|   */ | ||||
| lazy val InputVersion: Option[String] = | ||||
|   getProperty(VersionProperty, identity) | ||||
| 
 | ||||
| /** @return | ||||
|   *   "-SNAPSHOT" if this is NOT a release, empty string otherwise. | ||||
|   */ | ||||
| lazy val Modifier: String = | ||||
|   if (getProperty(ReleaseProperty, _.toBoolean).getOrElse(false)) "" | ||||
|   else "-SNAPSHOT" | ||||
| 
 | ||||
| /** Version used if no version is passed as input. This helps with default/local | ||||
|   * builds. | ||||
|   */ | ||||
| val DefaultVersion: String = "0.1.0-SNAPSHOT" | ||||
| 
 | ||||
| /** This is the output version of the published artifact. If this build is not a | ||||
|   * release, the suffix "-SNAPSHOT" will be appended. | ||||
|   * | ||||
|   * @return | ||||
|   *   The project version. | ||||
|   */ | ||||
| lazy val SelectedVersion: String = | ||||
|   InputVersion | ||||
|     .map(v => s"$v$Modifier") | ||||
|     .getOrElse(DefaultVersion) | ||||
| 
 | ||||
| /** The major version (first segment) value. Used to label releases. | ||||
|   * | ||||
|   * @return | ||||
|   *   The major version of the project. | ||||
|   */ | ||||
| lazy val MajorVersion: String = | ||||
|   SelectedVersion.split('.').apply(0) | ||||
| 
 | ||||
| val sharedSettings = Seq( | ||||
| lazy val sharedSettings = Seq( | ||||
|   scalaVersion := scala3, | ||||
|   version      := SelectedVersion | ||||
|   version      := semVerSelected.value | ||||
| ) | ||||
| 
 | ||||
| lazy val publishSettings = Seq( | ||||
|  | @ -100,9 +33,10 @@ lazy val publishSettings = Seq( | |||
|   ), | ||||
|   publishTo := { | ||||
|     val repo = "https://maven.garrity.co/" | ||||
|     if (SelectedVersion.endsWith("SNAPSHOT")) | ||||
|     if (semVerSnapshot.value) | ||||
|       Some("Garrity Software Maven" at repo + "snapshots") | ||||
|     else Some("Garrity Software Maven" at repo + "releases") | ||||
|     else | ||||
|       Some("Garrity Software Maven" at repo + "releases") | ||||
|   } | ||||
| ) | ||||
| 
 | ||||
|  | @ -117,7 +51,7 @@ lazy val `gs-config` = project | |||
|   .settings(sharedSettings) | ||||
|   .settings(publishSettings) | ||||
|   .settings(testSettings) | ||||
|   .settings(name := s"$ProjectName-v$MajorVersion") | ||||
|   .settings(name := s"$ProjectName-v${semVerMajor.value}") | ||||
|   .settings( | ||||
|     libraryDependencies ++= Seq( | ||||
|       "org.typelevel" %% "cats-effect" % "3.5.2" | ||||
|  |  | |||
|  | @ -1 +1,9 @@ | |||
| credentials += Credentials(Path.userHome / ".sbt" / ".credentials") | ||||
| 
 | ||||
| externalResolvers := Seq( | ||||
|   "Garrity Software Mirror" at "https://maven.garrity.co/releases", | ||||
|   "Garrity Software Releases" at "https://maven.garrity.co/gs" | ||||
| ) | ||||
| 
 | ||||
| addSbtPlugin("org.scoverage" % "sbt-scoverage"        % "2.0.8") | ||||
| addSbtPlugin("gs"            % "gs-semver-sbt-plugin" % "0.1.1") | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue