From 9d7d67c8c8a4dc5a20cb72db50d7c10bc343a18c Mon Sep 17 00:00:00 2001 From: Joel Dickson Date: Fri, 13 Sep 2024 09:10:22 +0700 Subject: [PATCH] add publish for scala package --- .github/workflows/scalabuild.yml | 15 ++++++++++++++ scalatest-listener/build.sbt | 29 ++++++++++++++++++++++++++- scalatest-listener/project/plugin.sbt | 4 ++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 scalatest-listener/project/plugin.sbt diff --git a/.github/workflows/scalabuild.yml b/.github/workflows/scalabuild.yml index 0b74841..68092b7 100644 --- a/.github/workflows/scalabuild.yml +++ b/.github/workflows/scalabuild.yml @@ -37,6 +37,21 @@ jobs: working-directory: scalatest-listener run: sbt compile + - name: Import GPG key + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_SECRET_KEY }} + working-directory: scalatest-listener + run: | + echo "$GPG_PRIVATE_KEY" | gpg --import --batch + + - name: Publish to Maven Central + env: + SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + working-directory: scalatest-listener + run: sbt publishSigned sonatypeBundleRelease + # Optional: Add a step to publish the artifact if needed # - name: Publish artifact # working-directory: scalatest-listener diff --git a/scalatest-listener/build.sbt b/scalatest-listener/build.sbt index 46b0558..1c2f700 100644 --- a/scalatest-listener/build.sbt +++ b/scalatest-listener/build.sbt @@ -1,3 +1,5 @@ +import xerial.sbt.Sonatype._ + name := "scala-test-metrics" organization := "io.agodadev" version := "0.1.0-SNAPSHOT" @@ -13,4 +15,29 @@ libraryDependencies ++= Seq( "org.mockito" %% "mockito-scala-scalatest" % "1.17.12" % Test ) -testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-C", "io.agodadev.testmetricsscala.TestMetricsReporter") \ No newline at end of file +testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-C", "io.agodadev.testmetricsscala.TestMetricsReporter") + +// Maven Central publishing settings +publishMavenStyle := true +publishTo := sonatypePublishToBundle.value +sonatypeProjectHosting := Some(GitHubHosting("agoda-com", "scala-test-metrics", "maven@agoda.com")) +licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")) +homepage := Some(url("https://github.com/agoda-com/scala-test-metrics")) +scmInfo := Some( + ScmInfo( + url("https://github.com/agoda-com/scala-test-metrics"), + "scm:git@github.com:agoda-com/scala-test-metrics.git" + ) +) +developers := List( + Developer( + id = "joeldickson", + name = "Joel Dickson", + email = "maven@agoda.com", + url = url("http://beerandserversdontmix.com") + ) +) + +// PGP signing settings +usePgpKeyHex("849F9D2E") +pgpPassphrase := sys.env.get("GPG_PASSPHRASE").map(_.toArray) diff --git a/scalatest-listener/project/plugin.sbt b/scalatest-listener/project/plugin.sbt new file mode 100644 index 0000000..254ec54 --- /dev/null +++ b/scalatest-listener/project/plugin.sbt @@ -0,0 +1,4 @@ + +// Add these to your project/plugins.sbt if not already present +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") \ No newline at end of file