aboutsummaryrefslogtreecommitdiff
path: root/plugins/sonatype-release/src/SonatypeRelease.scala
blob: cc2932a19042ec3c8bfa7eea0dd1b68b0dd0202f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cbt
// TODO: maybe move this into stage2 to avoid having to call zinc separately for this as a plugin

import cbt.sonatype.SonatypeLib

/**
  * Sonatype release plugin.
  * It provides ability to release your artifacts to Sonatype OSSRH
  * and publish to Central repository (aka Maven Central).
  *
  * Release proccess is executed in two steps:
  * • `sonatypePublishSigned`
  *     - creates staging repository to publish artifacts;
  *     - publishes signed artifacts(jars) to staging repository.
  * • `sonatypeRelease`
  *     - closes staging repository;
  *     - promotes staging repository to Central repository;
  *     - drops staging repository after release.
  */
trait SonatypeRelease extends Publish {

  def profileName: String = groupId

  def sonatypeServiceURI: String = SonatypeLib.sonatypeServiceURI

  def sonatypeSnapshotsURI: String = SonatypeLib.sonatypeSnapshotsURI

  def sonatypeCredentials: String = SonatypeLib.sonatypeCredentials

  def sonatypePublishSigned: ExitCode =
    sonatypeLib.sonatypePublishSigned(
      sourceFiles,
      `package` :+ pom,
      groupId,
      artifactId,
      version,
      isSnapshot,
      scalaMajorVersion
    )

  def sonatypePublishSignedSnapshot: ExitCode = {
    copy(context.copy(version = Some(version + "-SNAPSHOT"))).sonatypePublishSigned
  }

  def sonatypeRelease: ExitCode =
    sonatypeLib.sonatypeRelease(groupId, artifactId, version)

  private def sonatypeLib =
    new SonatypeLib(sonatypeServiceURI, sonatypeSnapshotsURI, sonatypeCredentials, profileName)(lib)
}