Skip to content

Essential: Configuration

Miklós Martin edited this page Aug 31, 2018 · 15 revisions

Configure sbt-release-early

Install the plugin first.

Done? Alright, let's configure the plugin. Note that the following settings work with sbt 1.x and may or may not work for sbt 0.13.x. If you use 0.13.x, make sure you use 1.2.0 and ask questions in our Gitter channel.

Copy-paste the following settings to your build.sbt.

inThisBuild(List(
    // These are normal sbt settings to configure for release, skip if already defined
    licenses := Seq("YOUR_LICENSE" -> url("http://opensource.org/licenses/YOUR_LICENSE")),
    homepage := Some(url("https://github.com/$ORG/$PROJECT")),
    developers := List(Developer("$HANDLE", "$NAME", "$EMAIL", url("$YOUR_WEBSITE"))),
    scmInfo := Some(ScmInfo(url("$YOUR_REPO_URL"), "scm:git:git@github.com:$YOUR_ORG/$YOUR_REPO_NAME.git")),

    // These are the sbt-release-early settings to configure
    pgpPublicRing := file("/keys/.gnupg/pubring.asc"),
    pgpSecretRing := file("/keys/.gnupg/secring.asc"),
    releaseEarlyWith := SonatypePublisher
))

Let's have a closer look at the previous snippet:

  • All settings are scoped globally because they are not project or build-dependent.
  • Only pgpPublicRing, pgpSecretRing and releaseEarlyWith are specific to this plugin.
  • The settings licenses, homepage, developers and scmInfo are common sbt settings.

That is the bare minimum you need to have a working sbt build that publishes to your favorite repository. Let's dive into the specific settings you need to define:

  1. releaseEarlyWith: the setting that defines the publisher that releaseEarly uses.
  2. pgpPublicRing: The gpg setting that tells sbt-release-early where to find your public key.
  3. pgpSecretRing: The gpg setting that tells sbt-release-early where to find your secret key.

You're done with the basic configuration of the plugin. Before commiting these changes, you need to set up the CI. For that, have a look at the How To guides in the right sidebar.

Defaults

The default configuration consists of keys that need to rarely change. The default sbt-release-early:

  • Releases on merge.
  • Releases on tag and synchronizes to Maven Central.
  • Uses your VCS information to fill in package's metadata (scmInfo).
  • Configures the version depending on your commit (via sbt-dynver).
  • Uses Sonatype as the underlying publisher.
  • Does not release a project that has already been released (e.g. can be resolved).

If you want to try your setup with a random version locally, you can define releaseEarlyEnableLocalReleases := true in your projects so that local releases are enabled. This is not recommended, releases should happen in isolated environments like a CI.

You can change the default publisher to Bintray by adding the following line to the previous list (remember, scoped in Global):

releaseEarlyWith := BintrayPublisher

For a more advanced configuration, you're welcome to ask in the Gitter channel or read the sources, which have been written to be easily hackable and readable.