Skip to content

Commit

Permalink
Merge pull request #41 from armanbilge/topic/ci-release-config
Browse files Browse the repository at this point in the history
Improve CI release config
  • Loading branch information
armanbilge authored Jan 2, 2022
2 parents 685aaba + c5de24d commit 08387da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ ThisBuild / organizationName := "Typelevel"
ThisBuild / scalaVersion := "2.12.15"

enablePlugins(TypelevelCiReleasePlugin)
ThisBuild / tlCiReleaseSnapshots := true
ThisBuild / tlCiReleaseBranches := Seq("main")

ThisBuild / developers := List(
tlGitHubDev("armanbilge", "Arman Bilge"),
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/org/typelevel/sbt/TypelevelPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object TypelevelPlugin extends AutoPlugin {
import autoImport._
import TypelevelKernelPlugin.autoImport._
import TypelevelSettingsPlugin.autoImport._
import TypelevelSonatypeCiReleasePlugin.autoImport._
import GenerativePlugin.autoImport._
import GitHubActionsPlugin.autoImport._

Expand All @@ -54,6 +55,7 @@ object TypelevelPlugin extends AutoPlugin {
organizationName := "Typelevel",
startYear := Some(java.time.YearMonth.now().getYear()),
licenses += "Apache-2.0" -> url("http://www.apache.org/licenses/"),
tlCiReleaseBranches := Seq("main"),
Def.derive(tlFatalWarnings := (tlFatalWarningsInCi.value && githubIsWorkflowBuild.value)),
githubWorkflowBuildMatrixExclusions ++= {
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import sbtghactions.GenerativePlugin.autoImport._
object TypelevelSonatypeCiReleasePlugin extends AutoPlugin {

object autoImport {
lazy val tlCiReleaseSnapshots = settingKey[Boolean](
"Controls whether or not snapshots should be released (default: false)")
lazy val tlCiReleaseBranches =
settingKey[Seq[String]]("The branches in your repository to release from (default: [])")
lazy val tlCiReleaseTags = settingKey[Boolean](
"Controls whether or not v-prefixed tags should be released from CI (default true)")
lazy val tlCiReleaseBranches = settingKey[Seq[String]](
"The branches in your repository to release from in CI on every push. Depending on your versioning scheme, they will be either snapshots or (hash) releases. Leave this empty if you only want CI releases for tags. (default: [])")
}

import autoImport._
Expand All @@ -38,21 +38,24 @@ object TypelevelSonatypeCiReleasePlugin extends AutoPlugin {
override def trigger = noTrigger

override def globalSettings =
Seq(tlCiReleaseSnapshots := false, tlCiReleaseBranches := Seq())
Seq(tlCiReleaseTags := true, tlCiReleaseBranches := Seq())

override def buildSettings = Seq(
githubWorkflowEnv ++= Map(
"SONATYPE_USERNAME" -> s"$${{ secrets.SONATYPE_USERNAME }}",
"SONATYPE_PASSWORD" -> s"$${{ secrets.SONATYPE_PASSWORD }}"
),
githubWorkflowPublishTargetBranches := {
val seed =
if (tlCiReleaseSnapshots.value)
tlCiReleaseBranches.value.map(b => RefPredicate.Equals(Ref.Branch(b)))
val branches =
tlCiReleaseBranches.value.map(b => RefPredicate.Equals(Ref.Branch(b)))

val tags =
if (tlCiReleaseTags.value)
Seq(RefPredicate.StartsWith(Ref.Tag("v")))
else
Seq.empty

RefPredicate.StartsWith(Ref.Tag("v")) +: seed
tags ++ branches
},
githubWorkflowTargetTags += "v*",
githubWorkflowPublish := Seq(
Expand Down

0 comments on commit 08387da

Please sign in to comment.