Skip to content

Commit

Permalink
Configure project for git hash versioning (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru committed Jun 4, 2017
1 parent df8b01d commit 7a337f9
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 31 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ Monix 2.x is modular by design, so you can pick and choose:
and depends on `monix-eval`
- `monix` provides all of the above

### Versioning Scheme

The versioning scheme follows the
[Semantic Versioning](http://semver.org/) (semver) specification,
meaning that stable versions have the form `$major.$minor.$patch`,
such that:

1. `$major` version updates make binary incompatible API changes
2. `$minor` version updates adds functionality in a
backwards-compatible manner, and
3. `$patch` version updates makes backwards-compatible bug fixes

For development snapshots may be published to Sonatype at any time.
Development versions have the form: `$major.$minor.$patch-$hash`
(example `3.0.0-3cc55ae`).

The `$hash` is the 7 character git hash prefix of the commit from
which the snapshot was published. Thus, "snapshots" can be used as
repeatable upstream dependencies if you're feeling courageous. NO
GUARANTEE is made for upgrades of development versions, use these at
your own risk.

## Documentation

NOTE: The documentation is a work in progress. All documentation is
Expand Down
77 changes: 48 additions & 29 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import com.typesafe.sbt.pgp.PgpKeys
import com.typesafe.sbt.GitVersioning
import sbt.Keys.version
// For getting Scoverage out of the generated POM
import scala.xml.Elem
import scala.xml.transform.{RewriteRule, RuleTransformer}

addCommandAlias("ci-jvm-all", ";clean ;coreJVM/test:compile ;tckTests/test:compile ;coreJVM/test ;tckTests/test ;mimaReportBinaryIssues ;unidoc")
addCommandAlias("ci-jvm", ";clean ;coreJVM/test:compile ;tckTests/test:compile ;coreJVM/test ;tckTests/test")
addCommandAlias("ci-js", ";clean ;coreJS/test:compile ;coreJS/test")
addCommandAlias("release", ";project monix ;reload; +clean; +test:compile ;+package ;+publishSigned")

val catsVersion = "0.9.0"
val catsEffectVersion = "0.3"
Expand Down Expand Up @@ -144,23 +146,21 @@ lazy val sharedSettings = warnUnusedImport ++ Seq(
incOptions := incOptions.value.withLogRecompileOnMacro(false),

// -- Settings meant for deployment on oss.sonatype.org
sonatypeProfileName := organization.value,

useGpg := true,
useGpgAgent := true,
usePgpKeyHex("2673B174C4071B0E"),

publishMavenStyle := true,
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,

publishTo := {
val nexus = "https://oss.sonatype.org/"
publishTo := Some(
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
Opts.resolver.sonatypeSnapshots
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
Opts.resolver.sonatypeStaging
),

isSnapshot := version.value endsWith "SNAPSHOT",
publishArtifact in Test := false,
pomIncludeRepository := { _ => false }, // removes optional dependencies

Expand All @@ -176,26 +176,22 @@ lazy val sharedSettings = warnUnusedImport ++ Seq(
}).transform(node).head
},

pomExtra :=
<url>https://monix.io/</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:monix/monix.git</url>
<connection>scm:git:git@github.com:monix/monix.git</connection>
</scm>
<developers>
<developer>
<id>alexelcu</id>
<name>Alexandru Nedelcu</name>
<url>https://alexn.org</url>
</developer>
</developers>
licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://monix.io")),

scmInfo := Some(
ScmInfo(
url("https://github.com/monix/monix"),
"scm:git@github.com:monix/monix.git"
)),

developers := List(
Developer(
id="alexelcu",
name="Alexandru Nedelcu",
email="noreply@alexn.org",
url=url("https://alexn.org")
))
)

lazy val crossSettings = sharedSettings ++ Seq(
Expand Down Expand Up @@ -401,3 +397,26 @@ lazy val benchmarks = project.in(file("benchmarks"))
)
)


//------------- For Release

enablePlugins(GitVersioning)

/* The BaseVersion setting represents the in-development (upcoming) version,
* as an alternative to SNAPSHOTS.
*/
git.baseVersion := "3.0.0"

val ReleaseTag = """^v([\d\.]+)$""".r
git.gitTagToVersionNumber := {
case ReleaseTag(v) => Some(v)
case _ => None
}

git.formattedShaVersion := {
val suffix = git.makeUncommittedSignifierSuffix(git.gitUncommittedChanges.value, git.uncommittedSignifier.value)

git.gitHeadCommit.value map { _.substring(0, 7) } map { sha =>
git.baseVersion.value + "-" + sha + suffix
}
}
3 changes: 2 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.17")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.4")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.24")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit 7a337f9

Please sign in to comment.