Install PGP plugin Reference
For sbt 0.13.5+: Add the following to your ~/.sbt/0.13/plugins/gpg.sbt file:
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
PGP Gen Key Reference
> pgp-cmd gen-key
java.lang.RuntimeException: Cannot modify keyrings when in read-only mode. Run `set pgpReadOnly := false` before running this command.
> set pgpReadOnly := false
[info] Defining */*:pgpReadOnly
> pgp-cmd gen-key
Please enter the name associated with the key: joecwu
Please enter the email associated with the key: joe623@gmail.com
Please enter the passphrase for the key: *********
Please re-enter the passphrase for the key: *********
[info] Creating a new PGP key, this could take a long time.
[info] Public key := C:\Users\Joe\.sbt\gpg\pubring.asc
[info] Secret key := C:\Users\Joe\.sbt\gpg\secring.asc
[info] Please do not share your secret key. Your public key is free to share.
Upload public key Reference
> pgp-cmd send-key joecwu hkp://pool.sks-keyservers.net
[info] Sending PublicKeyRing(PublicKey(a4182f2a8c5e77fa, joecwu <joe623@gmail.com>, RSA@2048)) to HkpServer(http://pool.sks-keyservers.net:11371)
INF: [console logger] dispatch: pool.sks-keyservers.net POST /pks/add HTTP/1.1
Deploy to Sonatype Reference
credentials += Credentials("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
"your-sonatype-username",
"your-sonatype-password")
// Your profile name of the sonatype account. The default is the same with the organization value
sonatypeProfileName := "com.joecwu"
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
organization := "com.joecwu"
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := { _ => false }
pomExtra in Global := (
<url>http://blog.joecwu.com/search/label/jcwutil</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/joecwu/jcwutil</url>
<connection>scm:git:git://github.com/joecwu/jcwutil.git</connection>
<developerConnection>scm:git:git@github.com:joecwu/jcwutil.git</developerConnection>
</scm>
<developers>
<developer>
<id>joecwu</id>
<name>Joe Wu</name>
<email>joecwu@gmail.com</email>
<url>https://github.com/joecwu</url>
</developer>
</developers>
)
> publishLocalSigned
[info] Done updating.
[info] :: delivering :: default#jcwutil_2.11;0.0.1 :: 0.0.1 :: release :: Wed Jul 22 01:59:08 CST 2015
[info] delivering ivy file to S:\IdeaWorkspace\jcwutil\target\scala-2.11\ivy-0.0.1.xml
[info] Main Scala API documentation to S:\IdeaWorkspace\jcwutil\target\scala-2.11\api...
[info] 'compiler-interface' not yet compiled for Scala 2.11.6. Compiling...
[info] Compiling 1 Scala source to S:\IdeaWorkspace\jcwutil\target\scala-2.11\classes...
[info] Compilation completed in 10.787 s
[warn] there were two feature warnings; re-run with -feature for details
model contains 7 documentable templates
[warn] there were two feature warnings; re-run with -feature for details
[warn] one warning found
[warn] No main class detected
[info] Packaging S:\IdeaWorkspace\jcwutil\target\scala-2.11\jcwutil_2.11-0.0.1.jar ...
[info] Done packaging.
[warn] one warning found
[info] Main Scala API documentation successful.
[info] Packaging S:\IdeaWorkspace\jcwutil\target\scala-2.11\jcwutil_2.11-0.0.1-javadoc.jar ...
[info] Done packaging.
Please enter PGP passphrase (or ENTER to abort): *********
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\poms\jcwutil_2.11.pom.asc
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\jars\jcwutil_2.11.jar
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\docs\jcwutil_2.11-javadoc.jar.asc
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\jars\jcwutil_2.11.jar.asc
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\srcs\jcwutil_2.11-sources.jar
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\srcs\jcwutil_2.11-sources.jar.asc
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\poms\jcwutil_2.11.pom
[info] published jcwutil_2.11 to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\docs\jcwutil_2.11-javadoc.jar
[info] published ivy to C:\Users\Joe\.ivy2\local\default\jcwutil_2.11\0.0.1\ivys\ivy.xml
> publishSigned
[info] Wrote S:\IdeaWorkspace\jcwutil\target\scala-2.11\jcwutil_2.11-0.0.1.pom
[info] :: delivering :: default#jcwutil_2.11;0.0.1 :: 0.0.1 :: release :: Wed Jul 22 03:05:00 CST 2015
[info] delivering ivy file to S:\IdeaWorkspace\jcwutil\target\scala-2.11\ivy-0.0.1.xml
[warn] No main class detected
Please enter PGP passphrase (or ENTER to abort): *********
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1.pom.asc
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1.jar
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1-javadoc.jar.asc
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1.jar.asc
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1-sources.jar
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1-sources.jar.asc
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1.pom
[info] published jcwutil_2.11 to https://oss.sonatype.org/service/local/staging/deploy/maven2/default/jcwutil_2.11/0.0.1/jcwutil_2.11-0.0.1-javadoc.jar
[success] Total time: 15 s, completed 2015/7/22 上午 03:05:16
Release by using sbt-sonatype plugin (https://github.com/xerial/sbt-sonatype)
> sonatypeRelease
[info] Nexus repository URL: https://oss.sonatype.org/service/local
[info] Reading staging repository profiles...
[info] Reading staging profiles...
[info] Closing staging repository [comjoecwu-1001] status:open, profile:com.joecwu(23f357c5fbaeb2)
[info] Activity open started:2015-07-21T19:58:00.527Z, stopped:2015-07-21T19:58:02.379Z
[info] repositoryCreated: id:comjoecwu-1001, user:joecwu, ip:122.116.184.156
[info] Activity close started:2015-07-21T19:58:28.109Z, stopped:
[info] Evaluate: id:5e9e8e6f8d20a3, rule:sources-staging
[info] Evaluate: javadoc-staging
[info] Passed: javadoc-staging
[info] Evaluate: signature-staging
[info] Passed: signature-staging
[info] Evaluate: checksum-staging
[info] Passed: checksum-staging
[info] Evaluate: sources-staging
[info] Passed: sources-staging
[info] Evaluate: pom-staging
[info] Passed: pom-staging
[info] Passed: id:5e9e8e6f8d20a3
[info] email: to:joe623@gmail.com
[info] repositoryClosed: id:comjoecwu-1001
[info] Closed successfully
[info] Promoting staging repository [comjoecwu-1001] status:closed, profile:com.joecwu(23f357c5fbaeb2)
[info] Activity release started:2015-07-21T19:58:37.359Z, stopped:
[info] Evaluate: id:5e9e8e6f8d20a3, rule:sources-staging
[info] Evaluate: javadoc-staging
[info] Passed: javadoc-staging
[info] Evaluate: pom-staging
[info] Passed: pom-staging
[info] Evaluate: checksum-staging
[info] Passed: checksum-staging
[info] Evaluate: sources-staging
[info] Passed: sources-staging
[info] Evaluate: signature-staging
[info] Passed: signature-staging
[info] Passed: id:5e9e8e6f8d20a3
[info] Evaluate: id:nx-internal-ruleset, rule:RepositoryWritePolicy
[info] Evaluate: RepositoryWritePolicy
[info] Passed: RepositoryWritePolicy
[info] Passed: id:nx-internal-ruleset
[info] copyItems: source:comjoecwu-1001, target:releases
[info] email: to:joe623@gmail.com
[info] repositoryReleased: id:comjoecwu-1001, target:releases
[info] Promoted successfully
[info] Dropping staging repository [comjoecwu-1001] status:released, profile:com.joecwu(23f357c5fbaeb2)
[info] Dropped successfully: comjoecwu-1001