Skip to content

Commit 2f8df24

Browse files
authored
Publish to Sonatype (#1)
* Publish to Sonatype * fix organization in sbt-test
1 parent 5351b70 commit 2f8df24

File tree

6 files changed

+73
-34
lines changed

6 files changed

+73
-34
lines changed

.github/workflows/sbt.yml

+20-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: olafurpg/setup-scala@v10
12+
with:
13+
java-version: "[email protected]"
14+
- uses: coursier/cache-action@v5
15+
- uses: jrouly/scalafmt-native-action@v1
16+
- run: csbt +test +scripted
17+
18+
release:
19+
needs: [build]
20+
runs-on: ubuntu-latest
21+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
922
steps:
1023
- uses: actions/checkout@v2
1124
with:
@@ -14,10 +27,11 @@ jobs:
1427
with:
1528
java-version: "[email protected]"
1629
- uses: coursier/cache-action@v5
17-
- uses: jrouly/scalafmt-native-action@v1
18-
- run: csbt ^test ^scripted
19-
- run: csbt ^publish
20-
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
30+
- uses: crazy-max/ghaction-import-gpg@v3
31+
with:
32+
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
33+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
34+
- run: csbt +publishSigned
2135
env:
22-
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
23-
ARTIFACTORY_PASS: ${{ secrets.ARTIFACTORY_PASS }}
36+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
37+
SONATYPE_PASS: ${{ secrets.SONATYPE_PASS }}

README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# sbt-openapi-diff
22

33
[![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)
4-
[![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)
5-
64

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

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

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

1815
Update your `build.sbt`:

build.sbt

+8-23
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
name := "sbt-openapi-diff"
2-
organization := "org.openapitools.openapidiff"
2+
organization := "net.rouly"
33
description := "Supports functionality from openapi-diff as part of an sbt build."
44

5-
homepage := Some(url("https://github.com/jrouly/sbt-openapi-diff"))
6-
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
7-
85
scriptedBufferLog := false
96
scriptedLaunchOpts ++= Seq("-Xmx1024M", "-server", "-Dplugin.version=" + version.value)
107

118
Global / onChangedBuildSource := ReloadOnSourceChanges
129

1310
enablePlugins(SbtPlugin)
14-
sbtPlugin := true
15-
16-
crossSbtVersions := List(
17-
"0.13.18",
18-
"1.1.6" // https://github.com/sbt/sbt/issues/5049
19-
)
2011

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

23-
credentials += Credentials(
24-
"Artifactory Realm",
25-
"jrouly.jfrog.io",
26-
sys.env.getOrElse("ARTIFACTORY_USER", "user"),
27-
sys.env.getOrElse("ARTIFACTORY_PASS", "pass")
28-
)
14+
crossScalaVersions := Seq("2.10.7", "2.12.10")
2915

30-
publishMavenStyle := false
31-
publishTo := {
32-
def resolver(host: String, repo: String) =
33-
Resolver.url(repo, url(s"https://$host/artifactory/$repo"))(Resolver.ivyStylePatterns)
34-
if (isSnapshot.value) Some(resolver("jrouly.jfrog.io", "ivy-snapshot-local"))
35-
else Some(resolver("jrouly.jfrog.io", "ivy-release-local"))
16+
pluginCrossBuild / sbtVersion := {
17+
scalaBinaryVersion.value match {
18+
case "2.10" => "0.13.18"
19+
case "2.12" => "1.1.6" // https://github.com/sbt/sbt/issues/5049
20+
}
3621
}

project/plugins.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
// Versions the build.
22
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
3+
4+
// Sign releases.
5+
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

publish.sbt

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
2+
import sbt._
3+
4+
organizationHomepage := Some(url("https://openapi-generator.tech/"))
5+
homepage := Some(url("https://openapi-generator.tech/"))
6+
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
7+
8+
scmInfo := Some(
9+
ScmInfo(
10+
url("https://github.com/jrouly/sbt-openapi-diff"),
11+
"scm:[email protected]:jrouly/sbt-openapi-diff.git"
12+
)
13+
)
14+
15+
developers := List(
16+
Developer(
17+
id = "jrouly",
18+
name = "Michel Rouly",
19+
email = "[email protected]",
20+
url = url("https://michel.rouly.net")
21+
)
22+
)
23+
24+
credentials += Credentials(
25+
realm = "Sonatype Nexus Repository Manager",
26+
host = "s01.oss.sonatype.org",
27+
userName = sys.env.getOrElse("SONATYPE_USER", "username"),
28+
passwd = sys.env.getOrElse("SONATYPE_PASS", "password")
29+
)
30+
31+
pomIncludeRepository := { _ => false }
32+
pgpSigningKey := Some("0xFA8B833314500A89")
33+
34+
publishMavenStyle := true
35+
36+
publishTo := Some {
37+
val nexus = "https://s01.oss.sonatype.org/"
38+
if (isSnapshot.value) "snapshots" at nexus + "content/repositories/snapshots"
39+
else "releases" at nexus + "service/local/staging/deploy/maven2"
40+
}

src/sbt-test/sbt-openapi-generator/simple/project/plugin.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ resolvers ++= Seq(
22
Resolver.sonatypeRepo("snapshots")
33
)
44
sys.props.get("plugin.version") match {
5-
case Some(x) => addSbtPlugin("org.openapitools.openapidiff" % "sbt-openapi-diff" % x)
5+
case Some(x) => addSbtPlugin("net.rouly" % "sbt-openapi-diff" % x)
66
case _ =>
77
throw new Exception("The system property 'plugin.version' is not defined.")
88
}

0 commit comments

Comments
 (0)