Skip to content

Commit

Permalink
Publish to Sonatype (#1)
Browse files Browse the repository at this point in the history
* Publish to Sonatype

* fix organization in sbt-test
  • Loading branch information
jrouly authored Dec 11, 2021
1 parent 5351b70 commit 2f8df24
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 34 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/sbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "adopt@1.8"
- uses: coursier/cache-action@v5
- uses: jrouly/scalafmt-native-action@v1
- run: csbt +test +scripted

release:
needs: [build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -14,10 +27,11 @@ jobs:
with:
java-version: "adopt@1.8"
- uses: coursier/cache-action@v5
- uses: jrouly/scalafmt-native-action@v1
- run: csbt ^test ^scripted
- run: csbt ^publish
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
- uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- run: csbt +publishSigned
env:
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASS: ${{ secrets.SONATYPE_PASS }}
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# sbt-openapi-diff

[![Scala CI](https://github.com/jrouly/sbt-openapi-diff/workflows/Scala%20CI/badge.svg?branch=master)](https://github.com/jrouly/sbt-openapi-diff/actions?query=workflow%3A%22Scala+CI%22)
[![Download](https://api.bintray.com/packages/jrouly/sbt-plugins/sbt-openapi-diff/images/download.svg)](https://bintray.com/jrouly/sbt-plugins/sbt-openapi-diff/_latestVersion)


An sbt plugin to support the [OpenAPI Diff](https://github.com/OpenAPITools/openapi-diff) project.

Expand All @@ -11,8 +9,7 @@ An sbt plugin to support the [OpenAPI Diff](https://github.com/OpenAPITools/open
Add to your `project/plugins.sbt`:

```sbt
resolvers += Resolver.bintrayIvyRepo("jrouly", "sbt-plugins")
addSbtPlugin("org.openapitools.openapidiff" % "sbt-openapi-diff" % "version")
addSbtPlugin("net.rouly" % "sbt-openapi-diff" % "version")
```

Update your `build.sbt`:
Expand Down
31 changes: 8 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
name := "sbt-openapi-diff"
organization := "org.openapitools.openapidiff"
organization := "net.rouly"
description := "Supports functionality from openapi-diff as part of an sbt build."

homepage := Some(url("https://github.com/jrouly/sbt-openapi-diff"))
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

scriptedBufferLog := false
scriptedLaunchOpts ++= Seq("-Xmx1024M", "-server", "-Dplugin.version=" + version.value)

Global / onChangedBuildSource := ReloadOnSourceChanges

enablePlugins(SbtPlugin)
sbtPlugin := true

crossSbtVersions := List(
"0.13.18",
"1.1.6" // https://github.com/sbt/sbt/issues/5049
)

libraryDependencies += "org.openapitools.openapidiff" % "openapi-diff-core" % "2.0.0-beta.6"
libraryDependencies += "org.openapitools.openapidiff" % "openapi-diff-core" % "2.0.0"

credentials += Credentials(
"Artifactory Realm",
"jrouly.jfrog.io",
sys.env.getOrElse("ARTIFACTORY_USER", "user"),
sys.env.getOrElse("ARTIFACTORY_PASS", "pass")
)
crossScalaVersions := Seq("2.10.7", "2.12.10")

publishMavenStyle := false
publishTo := {
def resolver(host: String, repo: String) =
Resolver.url(repo, url(s"https://$host/artifactory/$repo"))(Resolver.ivyStylePatterns)
if (isSnapshot.value) Some(resolver("jrouly.jfrog.io", "ivy-snapshot-local"))
else Some(resolver("jrouly.jfrog.io", "ivy-release-local"))
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
case "2.10" => "0.13.18"
case "2.12" => "1.1.6" // https://github.com/sbt/sbt/issues/5049
}
}
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// Versions the build.
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")

// Sign releases.
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
40 changes: 40 additions & 0 deletions publish.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
import sbt._

organizationHomepage := Some(url("https://openapi-generator.tech/"))
homepage := Some(url("https://openapi-generator.tech/"))
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

scmInfo := Some(
ScmInfo(
url("https://github.com/jrouly/sbt-openapi-diff"),
"scm:git@github.com:jrouly/sbt-openapi-diff.git"
)
)

developers := List(
Developer(
id = "jrouly",
name = "Michel Rouly",
email = "michel@rouly.net",
url = url("https://michel.rouly.net")
)
)

credentials += Credentials(
realm = "Sonatype Nexus Repository Manager",
host = "s01.oss.sonatype.org",
userName = sys.env.getOrElse("SONATYPE_USER", "username"),
passwd = sys.env.getOrElse("SONATYPE_PASS", "password")
)

pomIncludeRepository := { _ => false }
pgpSigningKey := Some("0xFA8B833314500A89")

publishMavenStyle := true

publishTo := Some {
val nexus = "https://s01.oss.sonatype.org/"
if (isSnapshot.value) "snapshots" at nexus + "content/repositories/snapshots"
else "releases" at nexus + "service/local/staging/deploy/maven2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)
sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("org.openapitools.openapidiff" % "sbt-openapi-diff" % x)
case Some(x) => addSbtPlugin("net.rouly" % "sbt-openapi-diff" % x)
case _ =>
throw new Exception("The system property 'plugin.version' is not defined.")
}

0 comments on commit 2f8df24

Please sign in to comment.