Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Oct 18, 2024
1 parent 5b37933 commit 60b5e0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
version=3.8.3
maxColumn = 140
maxColumn=140
dialect=scala212
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.softwaremill
import sbt._
import Keys._
import net.vonbuchholtz.sbt.dependencycheck.DependencyCheckPlugin
import java.net.URI

object SbtSoftwareMillExtra extends AutoPlugin {
override def requires = plugins.JvmPlugin
Expand All @@ -19,7 +20,7 @@ object SbtSoftwareMillExtra extends AutoPlugin {
)

lazy val dependencyCheckSettings = Seq(
DependencyCheckPlugin.autoImport.dependencyCheckCveUrlModified := Some(new URL("http://nvdmirror.sml.io/")),
DependencyCheckPlugin.autoImport.dependencyCheckCveUrlModified := Some(URI.create("http://nvdmirror.sml.io/").toURL()),
DependencyCheckPlugin.autoImport.dependencyCheckCveUrlBase := Some("http://nvdmirror.sml.io/"),
DependencyCheckPlugin.autoImport.dependencyCheckAssemblyAnalyzerEnabled := Some(false),
DependencyCheckPlugin.autoImport.dependencyCheckFormat := "All"
Expand Down
22 changes: 13 additions & 9 deletions publish/src/main/scala/com/softwaremill/Publish.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import sbt.Keys._
import sbt._
import sbtdynver.DynVerPlugin.autoImport.dynverTagPrefix
import xerial.sbt.Sonatype.autoImport.{sonatypeProfileName, sonatypeCredentialHost}
import java.net.URI

trait Publish {
lazy val ossPublishSettings = Seq(
Expand All @@ -18,7 +19,7 @@ trait Publish {
id = "softwaremill",
name = "SoftwareMill",
email = "[email protected]",
url = new URL("https://softwaremill.com")
url = URI.create("https://softwaremill.com").toURL()
)
),
updateDocs := UpdateVersionInDocs(sLog.value, organization.value, version.value),
Expand All @@ -34,26 +35,26 @@ trait Publish {
private val releaseCommand = Command.command("release") { state =>
var s = state
s.log.info("Current version:")
s = Command.process("version", s)
s = processCommandOrThrow("version", s)
val version = readNextVersion()

val tagPrefix = Project.extract(s).getOpt(ThisBuild / dynverTagPrefix).getOrElse("v")
val tag = tagPrefix + version

s = Command.process(s"""set ThisBuild/version := "$version"""", s)
s = processCommandOrThrow(s"""set ThisBuild/version := "$version"""", s)

val (s2, files) = Project.extract(s).runTask(updateDocs, s)
s = s2
s = addFilesToGit(s, files)

s.log.info(s"\nDocs updated, git status:\n")
s = Command.process(s"git status", s)
s = processCommandOrThrow(s"git status", s)
s.log.info(s"\n")

s = Command.process(s"""git commit -m "Release $version"""", s)
s = processCommandOrThrow(s"""git commit -m "Release $version"""", s)

s.log.info(s"Tagging release as: $tag")
s = Command.process(s"git tag $tag", s)
s = processCommandOrThrow(s"git tag $tag", s)

s = pushChanges(s)
s
Expand All @@ -68,16 +69,19 @@ trait Publish {

private def addFilesToGit(state: State, fs: Seq[File]): State =
fs.foldLeft(state) { case (s, f) =>
Command.process(s"git add ${f.getAbsolutePath}", s)
processCommandOrThrow(s"git add ${f.getAbsolutePath}", s)
}

private def pushChanges(state: State): State =
SimpleReader.readLine("Push changes? [y/n] ") match {
case Some("y") =>
val state2 = Command.process(s"git push", state)
Command.process(s"git push --tags", state2)
val state2 = processCommandOrThrow(s"git push", state)
processCommandOrThrow(s"git push --tags", state2)
case _ => sys.error("Aborting, not pushing changes"); state
}

private def processCommandOrThrow(command: String, state: State): State =
Command.process(command, state, msg => throw new RuntimeException(msg))
}

object Publish extends Publish

0 comments on commit 60b5e0e

Please sign in to comment.