@@ -21,6 +21,7 @@ import org.typelevel.sbt.gha.GenerativePlugin.autoImport._
21
21
import org .typelevel .sbt .gha .GitHubActionsPlugin
22
22
import sbt .Keys ._
23
23
import sbt ._
24
+ import xerial .sbt .Sonatype .autoImport ._
24
25
25
26
object TypelevelSonatypeCiReleasePlugin extends AutoPlugin {
26
27
@@ -41,6 +42,9 @@ object TypelevelSonatypeCiReleasePlugin extends AutoPlugin {
41
42
override def globalSettings =
42
43
Seq (tlCiReleaseTags := true , tlCiReleaseBranches := Seq ())
43
44
45
+ override def projectSettings =
46
+ Seq (commands += tlCiReleaseCommand)
47
+
44
48
override def buildSettings = Seq (
45
49
githubWorkflowEnv ++= List (
46
50
" SONATYPE_USERNAME" ,
@@ -60,48 +64,27 @@ object TypelevelSonatypeCiReleasePlugin extends AutoPlugin {
60
64
},
61
65
githubWorkflowTargetTags += " v*" ,
62
66
githubWorkflowPublish := Seq (
63
- WorkflowStep .Sbt (List (" tlRelease " ), name = Some (" Publish" ))
67
+ WorkflowStep .Sbt (List (" tlCiRelease " ), name = Some (" Publish" ))
64
68
)
65
69
)
66
70
67
- private def renderSummaryTable (results : Map [String , String ]): String =
68
- results
69
- .toList
70
- .map { case (k, v) => s " | ${k} | ${v} | " }
71
- .mkString(s " | Build Result | Value | \n | -: | :- | \n " , " \n " , " \n\n " )
72
-
73
- override def projectSettings : Seq [Setting [_]] = Seq (
74
- publish := {
75
- val result : Unit = publish.value
76
-
77
- val table : Map [String , String ] = {
78
- val map : Map [String , String ] = Map (" Release version" -> (ThisBuild / version).value)
79
- (ThisBuild / apiURL).value.map(_.toString).fold(map)(r => map + (" Api URL" -> r))
80
- }
81
- val projectName : String = name.value
82
- val maybeMavenResolverUrl : Option [(String , String )] =
83
- (ThisBuild / publishTo).value.collect {
84
- case x : MavenRepo => (x.name, x.root)
85
- case x : MavenRepository => (x.name, x.root)
86
- }
87
-
88
- val header : String = s " ### ${projectName} Publication Summary \n "
89
-
90
- val textToRender : String =
91
- maybeMavenResolverUrl.fold(renderSummaryTable(table)) {
92
- case (n, u) =>
93
- val newTable : Map [String , String ] = table + (" Resolver" -> s """ " ${n}" -> ${u}""" )
94
-
95
- val instructions : String =
96
- s " To configure your build to use this published version set \n " +
97
- s """ `resolvers += Resolver.url(" ${n}", url(" ${u}"))`\n\n """
98
-
99
- renderSummaryTable(newTable) + instructions
71
+ private def tlCiReleaseCommand : Command =
72
+ Command .command(" tlCiRelease" ) { state =>
73
+ val newState = Command .process(" tlRelease" , state)
74
+ newState.getSetting(version).foreach { v =>
75
+ val resolver = newState.getSetting(sonatypeDefaultResolver).fold(" " ) {
76
+ case repo : MavenRepository =>
77
+ s """ |```scala
78
+ |resolvers += " ${repo.name}" at " ${repo.root}"
79
+ |```
80
+ | """ .stripMargin
100
81
}
101
82
102
- GitHubActionsPlugin .appendtoStepSummary(header + textToRender)
103
-
104
- result
83
+ GitHubActionsPlugin .appendtoStepSummary(
84
+ s """ |## Published ` $v`
85
+ | ${resolver}""" .stripMargin
86
+ )
87
+ }
88
+ newState
105
89
}
106
- )
107
90
}
0 commit comments