From 267e6cbed7cdf5488b83de4ac453c57e3aa6bd66 Mon Sep 17 00:00:00 2001 From: Martin Mauch Date: Fri, 17 Feb 2023 16:09:01 +0100 Subject: [PATCH] Allow overriding stagingRelease --- README.md | 12 ++++++++++++ .../io/kipp/mill/ci/release/CiReleaseModule.scala | 15 +++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 11a7f8f..15416a1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala b/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala index 34af2ee..0e94144 100644 --- a/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala +++ b/plugin/src/io/kipp/mill/ci/release/CiReleaseModule.scala @@ -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 { @@ -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", "")} @@ -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." @@ -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}") @@ -135,7 +142,7 @@ object ReleaseModule extends ExternalModule { connectTimeout = 5000, log, awaitTimeout = 600000, - stagingRelease = true + stagingRelease = stagingRelease ).publishAll( release = true, artifactPaths: _*