From e691c3fc067ccddb923f70fef1ce1974217f3561 Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Fri, 3 Nov 2023 16:21:25 -0700 Subject: [PATCH] add publish commands --- .github/workflows/release.yml | 2 ++ build.sbt | 40 ++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 359ec7b..ed6bc25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,3 +23,5 @@ jobs: PGP_SECRET: ${{ secrets.PGP_SECRET }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + CI_RELEASE: publishSignedJdk8 + CI_SNAPSHOT_RELEASE: publishJdk8 diff --git a/build.sbt b/build.sbt index 994e41d..21e7819 100644 --- a/build.sbt +++ b/build.sbt @@ -21,7 +21,13 @@ lazy val root = (project in file(".")) ideSkipProject := false, compile / skip := true, publish / skip := true, - commands += testPlayVersionCommand + commands ++= Seq( + testPlayVersionCommand, + publishSignedJdk8, + publishSignedJdk11, + publishJdk8, + publishJdk11, + ) ) lazy val swagger = (projectMatrix in file(".")) @@ -156,6 +162,38 @@ lazy val testPlayVersionCommand = Command.single("testPlayVersion") { case (stat } } +lazy val publishSignedJdk8 = Command.command("publishSignedJdk8") { state => + requireJdkVersion("1.8.x") + publishCommands("publishSigned", play27, play28) ::: state +} + +lazy val publishSignedJdk11 = Command.command("publishSignedJdk11") { state => + requireJdkVersion("11.x") + publishCommands("publishSigned", play29, play30) ::: state +} + +lazy val publishJdk8 = Command.command("publishJdk8") { state => + requireJdkVersion("1.8.x") + publishCommands("publish", play27, play28) ::: state +} + +lazy val publishJdk11 = Command.command("publishJdk11") { state => + requireJdkVersion("11.x") + publishCommands("publish", play29, play30) ::: state +} + +def requireJdkVersion(semver: String): Unit = { + val version = VersionNumber(sys.props("java.specification.version")) + if (!version.matchesSemVer(SemanticSelector(semver))) { + sys.error(s"This build requires JDK $semver but found $version") + } +} + +def publishCommands(publishTask: String, versions: ConfigAxis*): List[String] = { + val projects = versions.toList.flatMap(ver => swagger.finder(ver).get) + projects.map(proj => s"+${proj.id}/$publishTask") +} + Global / excludeLintKeys += ideSkipProject ThisBuild / homepage := scmInfo.value.map(_.browseUrl)