Skip to content

Commit

Permalink
feat: publish to Sonatype (#12)
Browse files Browse the repository at this point in the history
* feat: publish to Sonatype #10
* fix: fmt
  • Loading branch information
polentino authored Mar 31, 2024
1 parent 43cfba6 commit 096e8ef
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 36 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![Actions Status](https://github.com/polentino/redacted/workflows/Scala%20CI/badge.svg)
![GitHub Tag](https://img.shields.io/github/v/tag/polentino/redacted?sort=semver&label=Latest%20Tag&color=blue)

![GitHub Tag](https://img.shields.io/github/v/tag/polentino/redacted?sort=semver&label=Latest%20Tag&color=limegreen)
![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/io.github.polentino/redacted_3.1.3?server=https%3A%2F%2Fs01.oss.sonatype.org&label=Sonatype%20-%20redacted&color=blue)
![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/io.github.polentino/redacted-plugin_3.1.3?server=https%3A%2F%2Fs01.oss.sonatype.org&label=Sonatype%20-%20redacted%20plugin&color=blue)

# Redacted

Expand Down Expand Up @@ -49,10 +50,11 @@ it be better if you were simply to say "when I dump **the whole object**, I don'
in your `build.sbt` file, add the following lines

```scala 3
resolvers += "GitHub" at "https://maven.pkg.github.com/polentino/redacted"
val redactedVersion = // use latest version of the library
resolvers += "Sonatype OSS Releases" at "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
libraryDependencies ++= Seq(
"io.github.polentino" % "redacted" % redactedVersion,
compilerPlugin("io.github.polentino" % "redacted-plugin" % redactedVersion cross CrossVersion.full)
"io.github.polentino" %% "redacted" % redactedVersion cross CrossVersion.full,
compilerPlugin("io.github.polentino" %% "redacted-plugin" % redactedVersion cross CrossVersion.full)
)
```

Expand Down
39 changes: 14 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ThisBuild / version := "0.3.1"
ThisBuild / scalaVersion := "3.1.3"

val organizeImportVersion = "0.6.0"
val scalaTestVersion = "3.2.17"
val scalaCheckVersion = "3.2.17.0"

// all LTS versions & latest minor ones
val supportedScalaVersions = List(
"3.1.3",
Expand All @@ -11,17 +14,6 @@ val supportedScalaVersions = List(
"3.4.0"
)

ThisBuild / crossScalaVersions := supportedScalaVersions
ThisBuild / publishMavenStyle := true
ThisBuild / crossPaths := false
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / publishTo := Some("GitHub Package Registry" at "https://maven.pkg.github.com/polentino/redacted")
ThisBuild / credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"polentino",
sys.env.getOrElse("GITHUB_TOKEN", "???"))

inThisBuild(
List(
organization := "io.github.polentino",
Expand All @@ -46,12 +38,13 @@ lazy val root = (project in file("."))
.settings(
name := "redacted-root",
crossScalaVersions := Nil,
test / skip := true,
publish / skip := true
)
.aggregate(redactedLibrary, redactedCompilerPlugin, redactedTests)

val scalafixSettings = Seq(
scalafixDependencies += "com.liancheng" %% "organize-imports" % "0.6.0",
scalafixDependencies += "com.liancheng" %% "organize-imports" % organizeImportVersion,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
Expand All @@ -68,14 +61,9 @@ lazy val redactedLibrary = (project in file("library"))
.settings(crossCompileSettings)

lazy val redactedCompilerPlugin = (project in file("plugin"))
.dependsOn(redactedLibrary)
.settings(name := "redacted-plugin")
.settings(crossCompileSettings)
.settings(
assembly / assemblyJarName := {
val assemblyJarFile = (Compile / Keys.`package`).value
assemblyJarFile.getName
},
crossCompileSettings,
libraryDependencies += "org.scala-lang" %% "scala3-compiler" % scalaVersion.value
)

Expand All @@ -85,19 +73,20 @@ lazy val redactedTests = (project in file("tests"))
.settings(scalafixSettings)
.settings(
publish / skip := true,
crossScalaVersions := supportedScalaVersions,
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.17" % Test,
"org.scalatestplus" %% "scalacheck-1-17" % "3.2.17.0" % Test
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"org.scalatestplus" %% "scalacheck-1-17" % scalaCheckVersion % Test
),
scalacOptions ++= {
val jar = (redactedCompilerPlugin / assembly).value
Test / scalacOptions ++= {
val jar = (redactedCompilerPlugin / Compile / packageBin).value
val addPlugin = "-Xplugin:" + jar.getAbsolutePath
val dummy = "-Jdummy=" + jar.lastModified
Seq(addPlugin, dummy)
}
)

addCommandAlias("testAll", "; +test")
addCommandAlias("publishAll", "; +publish")
addCommandAlias("testAll", "; clean; +test")
addCommandAlias("fmt", "; scalafix; scalafmtAll; scalafmtSbt")
addCommandAlias("fmtCheck", "; scalafmtCheckAll ; scalafmtSbtCheck")
addCommandAlias("crossReleaseAll", "; clean; +publishSigned; sonatypeBundleRelease")
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.core.{Flags, Symbols}

import io.github.polentino.redacted.redacted

object AstOps {
private val REDACTED_CLASS: String = classOf[redacted].getCanonicalName
private val REDACTED_CLASS: String = "io.github.polentino.redacted.redacted"

def redactedSymbol(using Context): ClassSymbol = Symbols.requiredClass(REDACTED_CLASS)

Expand Down
7 changes: 4 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
20 changes: 20 additions & 0 deletions sonatype.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import xerial.sbt.Sonatype.GitHubHosting

ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/polentino/redacted"),
"scm:[email protected]:polentino/redacted.git"
)
)
ThisBuild / publishMavenStyle := true
ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
ThisBuild / licenses := List("WTFPL" -> url("http://www.wtfpl.net/"))
ThisBuild / homepage := Some(url("https://github.com/polentino/redacted"))
ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
ThisBuild / sonatypeProjectHosting := Some(GitHubHosting("polentino", "redacted", "[email protected]"))
ThisBuild / developers := List(
Developer("polentino", "Diego Casella", "[email protected]", url("https://linkedin.com/in/diegocasella"))
)

usePgpKeyHex("8326E86A8331A3C871E392795045B78015B14EE0")
1 change: 1 addition & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ThisBuild / version := "0.4.0"

0 comments on commit 096e8ef

Please sign in to comment.