Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding stagingRelease #52

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ This will then set the correct `sonatypeUri` and `sonatypeSnapshotUri` for you.
If you have an older account, then there is no need to change the default or use
`sonatypeHost` at all.

### Using with custom Sonatype Nexus instances

If you're using your own instance of Sonatype Nexus, your configuration needs to be adapted slightly:
```diff
- override def sonatypeHost = Some(SonatypeHost.s01)
+ override def sonatypeUri = "https://your-sonatype-nexus.url/path/to/releases"
+ override def sonatypeSnapshotUri = "https://your-sonatype-nexus.url/path/to/snapshots"
+
+ // The Open Source version of Nexus does not support staging
+ override def stagingRelease = false
```

### GPG

If you've never created a keypair before that can be used to sign your artifacts
Expand Down
15 changes: 11 additions & 4 deletions plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ trait CiReleaseModule extends PublishModule {
"https://s01.oss.sonatype.org/content/repositories/snapshots"
case None => super.sonatypeSnapshotUri
}

def stagingRelease: Boolean = true
}

object ReleaseModule extends ExternalModule {
Expand All @@ -62,17 +64,18 @@ object ReleaseModule extends ExternalModule {
val modules = releaseModules(ev)

val uris = modules.map { m =>
(m.sonatypeUri, m.sonatypeSnapshotUri)
(m.sonatypeUri, m.sonatypeSnapshotUri, m.stagingRelease)
}

val sonatypeUris = uris.map(_._1).toSet
val sonatypeSnapshotUris = uris.map(_._2).toSet
val stagingReleases = uris.map(_._3).toSet

val allPomSettings = modules.map { m =>
Evaluator.evalOrThrow(ev)(m.pomSettings)
}

def mustBeUniqueMsg(value: String, values: Set[String]): String = {
def mustBeUniqueMsg[T](value: String, values: Set[T]): String = {
s"""It looks like you have multiple different values set for ${value}
|
|${values.mkString(" - ", " - \n", "")}
Expand All @@ -86,6 +89,10 @@ object ReleaseModule extends ExternalModule {
Result.Failure[Unit](
mustBeUniqueMsg("sonatypeSnapshotUri", sonatypeSnapshotUris)
)
} else if (stagingReleases.size != 1) {
Result.Failure[Unit](
mustBeUniqueMsg("stagingRelease", stagingReleases)
)
} else if (allPomSettings.flatMap(_.licenses).isEmpty) {
Result.Failure[Unit](
"You must have a license set in your PomSettings or Sonatype will silently fail."
Expand All @@ -99,7 +106,7 @@ object ReleaseModule extends ExternalModule {
// if they aren't size 1.
val sonatypeUri = sonatypeUris.head
val sonatypeSnapshotUri = sonatypeSnapshotUris.head

val stagingRelease = stagingReleases.head
if (env.isTag) {
log.info("Tag push detected, publishing a new stable release")
log.info(s"Publishing to ${sonatypeUri}")
Expand Down Expand Up @@ -135,7 +142,7 @@ object ReleaseModule extends ExternalModule {
connectTimeout = 5000,
log,
awaitTimeout = 600000,
stagingRelease = true
stagingRelease = stagingRelease
).publishAll(
release = true,
artifactPaths: _*
Expand Down