Skip to content

Instantly share code, notes, and snippets.

@Sciss
Forked from fdietze/Sbt Sonatype Publishing.md
Created October 10, 2017 15:24
Show Gist options
  • Save Sciss/507bd09b0110ba01f591c0a1428f2c4e to your computer and use it in GitHub Desktop.
Save Sciss/507bd09b0110ba01f591c0a1428f2c4e to your computer and use it in GitHub Desktop.
Sbt Sonatype

Create Account in Sonatype Issue tracker

https://issues.sonatype.org/projects/OSSRH

Create Issue with desired groupId

https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134

sonatype publishing

plugins.sbt

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

build.sbt:

pgpSecretRing in Global := file("secring.gpg")
pgpPublicRing in Global := file("pubring.gpg")
pgpPassphrase in Global := Some("".toCharArray)

organization in Global := "com.github.bla"

pomExtra := {
  <url>https://github.com/organisation/repository</url>
  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <scm>
    <url>https://github.com/organisation/repository</url>
    <connection>scm:git:git@github.com:organisation/repository.git</connection>
  </scm>
  <developers>
    <developer>
      <id>dev1</id>
      <name>Full Name</name>
      <url>https://github.com/dev1</url>
    </developer>
    <developer>
      <id>dev2</id>
      <name>Full Name</name>
      <url>https://github.com/dev2</url>
    </developer>
  </developers>
}

generate key pair and send to keyserver

$ sbt "set pgpReadOnly := false" "pgp-cmd gen-key"
$ sbt "set pgpReadOnly := false" "pgp-cmd send-key aaaabbbbccccdddd http://pgp.mit.edu:11371"

Store Sonatype credentials in separate sbt file

sonatype.sbt

import com.typesafe.sbt.SbtPgp._

// this has to go in an sbt file because if we use an external
// credentials properties file it ignores it
credentials in Global += Credentials(
  "Sonatype Nexus Repository Manager",
  "oss.sonatype.org",
  "username",
  "password"
)

Add Keyrings and credentials to .gitignore, to not accidentally commit them

*.gpg
sonatype.sbt

Publish Snapshots

$ sbt publishSigned

Publish Releases

$ sbt publishSigned
$ sbt sonatypeReleaseAll

Nexus Repository Manager

https://oss.sonatype.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment