Skip to content

Commit

Permalink
Configure publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
timaliberdov committed Jul 5, 2023
1 parent 7a27e2a commit d6c02d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
lazy val sbtKotlinPlugin = project.in(file("."))
.enablePlugins(SbtPlugin)
.settings(Publishing.settings)
.settings(
name := "sbt-kotlin-plugin",
organization := "org.jetbrains.scala",
Expand All @@ -9,5 +10,5 @@ lazy val sbtKotlinPlugin = project.in(file("."))
scalacOptions ++= Seq("-deprecation", "-feature", "-Werror", "-Xlint", "-release", "8"),
javacOptions ++= Seq("--release", "8"),

scriptedLaunchOpts += "-Dplugin.version=" + version.value
scriptedLaunchOpts += "-Dplugin.version=" + version.value,
)
28 changes: 28 additions & 0 deletions project/Publishing.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sbt.Keys.*
import sbt.{Credentials, Def, Path, fileToRichFile, toRepositoryName}

object Publishing {
private val loadCredentialsFromSystemPropsOrFile = credentials += {
val fromSystemProps = for {
user <- sys.props.get("scala_plugin_deps_user")
pwd <- sys.props.get("scala_plugin_deps_password")
} yield Credentials(realm = null, host = "packages.jetbrains.team", userName = user, passwd = pwd)

fromSystemProps
.getOrElse(Credentials(Path.userHome / ".sbt" / ".scala_plugin_deps_credentials"))
}

private val publishIfNotSnapshot = publish := {
if (isSnapshot.value)
sys.error("Do not publish snapshot versions. Set a tag 'vX.Y.Z' to proceed. Example: v3.20.2")
else
publish.value
}

val settings: Seq[Def.Setting[?]] = Seq(
publishTo := Some("Scala Plugin Dependencies" at "https://packages.jetbrains.team/maven/p/scl/scala-plugin-deps"),
versionScheme := Some("semver-spec"),
loadCredentialsFromSystemPropsOrFile,
publishIfNotSnapshot,
)
}

0 comments on commit d6c02d8

Please sign in to comment.