Skip to content

Commit

Permalink
Merge pull request #17 from dwickern/publish
Browse files Browse the repository at this point in the history
Automate releases with sbt-ci-release
  • Loading branch information
dwickern committed Nov 4, 2023
2 parents af62b2f + da6c95d commit e8b9884
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed
$CHANGES
22 changes: 22 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Drafter

on:
push:
branches:
- master

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release
on:
push:
branches: [master, main]
tags: ["*"]
jobs:
publish:
runs-on: ubuntu-20.04
strategy:
matrix:
java-version: [ 8, 11 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.java-version }}
cache: sbt
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
CI_RELEASE: publishSignedJdk${{ matrix.java-version }}
CI_SNAPSHOT_RELEASE: publishJdk${{ matrix.java-version }}
76 changes: 42 additions & 34 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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("."))
Expand All @@ -39,10 +45,6 @@ lazy val swagger = (projectMatrix in file("."))
Test / scalacOptions ~= filterConsoleScalacOptions,
Test / parallelExecution := false, // Swagger uses global state which breaks parallel tests
Test / publishArtifact := false,
publishTo := sonatypePublishToBundle.value,
pomIncludeRepository := { _ => false },
publishMavenStyle := true,
releaseCrossBuild := true,
ideSkipProject := true,
)
.customRow(
Expand Down Expand Up @@ -160,21 +162,43 @@ 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)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / pomExtra := {
<url>http://swagger.io</url>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:swagger-api/swagger-play.git</url>
<connection>scm:git:git@github.com:swagger-api/swagger-play.git</connection>
</scm>
<developers>
<developer>
<id>fehguy</id>
Expand Down Expand Up @@ -209,23 +233,7 @@ ThisBuild / pomExtra := {
<developer>
<id>dwickern</id>
<name>Derek Wickern</name>
<url>dwickern@gmail.com</url>
<email>dwickern@gmail.com</email>
</developer>
</developers>
}

import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
)
5 changes: 1 addition & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.7.0")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit e8b9884

Please sign in to comment.