Skip to content

Commit

Permalink
Expose tlSiteJavaVersion, auto-config to JDK 11+
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Nov 8, 2023
1 parent 02aeed8 commit 2ef6dd0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Ignore line ending differences in git
Expand Down
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pull_request_rules:
- status-success=Build and Test (macos-latest, 2.12, temurin@8, sbt-typelevelJVM)
- status-success=Build and Test (windows-latest, 2.12, temurin@8, sbt-typelevelJVM)
- status-success=Validate Steward Config (ubuntu-latest, temurin@11)
- status-success=Generate Site (ubuntu-latest, temurin@8)
- status-success=Generate Site (ubuntu-latest, temurin@11)
- '#approved-reviews-by>=1'
actions:
merge: {}
Expand Down
1 change: 1 addition & 0 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Using this plugin the following 2 settings have new default values:
- `tlSiteApiModule` (setting): The module that publishes API docs (default: `None`).
- `tlSiteApiPackage` (setting): The top-level package for your API docs (e.g. org.typlevel.sbt).
- `tlSiteKeepFiles` (setting): Whether to keep existing files when deploying site (default: `true`).
- `tlSiteJavaVersion` (setting): The Java version to use for the site job, must be >= 11 (default: first compatible choice from `githubWorkflowJavaVersions`, otherwise Temurin 11).
- `tlSiteGenerate` (setting): A sequence of workflow steps which generates the site (default: `[Sbt(List("tlSite"))]`).
- `tlSitePublish` (setting): A sequence of workflow steps which publishes the site (default: `peaceiris/actions-gh-pages`).
- `tlSitePublishBranch` (setting): The branch to publish the site from on every push. Set this to `None` if you only want to update the site on tag releases. (default: `main`)
Expand Down
34 changes: 30 additions & 4 deletions site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import sbt.Keys._
import sbt._

import scala.annotation.nowarn
import scala.util.Try

object TypelevelSitePlugin extends AutoPlugin {

Expand Down Expand Up @@ -58,6 +59,8 @@ object TypelevelSitePlugin extends AutoPlugin {

lazy val tlSiteKeepFiles =
settingKey[Boolean]("Whether to keep existing files when deploying site (default: true)")
lazy val tlSiteJavaVersion = settingKey[JavaSpec](
"The Java version to use for the site job, must be >= 11 (default: first compatible choice from `githubWorkflowJavaVersions`, otherwise Temurin 11)")
lazy val tlSiteGenerate = settingKey[Seq[WorkflowStep]](
"A sequence of workflow steps which generates the site (default: [Sbt(List(\"tlSite\"))])")
lazy val tlSitePublish = settingKey[Seq[WorkflowStep]](
Expand Down Expand Up @@ -92,6 +95,20 @@ object TypelevelSitePlugin extends AutoPlugin {
tlSiteApiPackage := None,
tlSiteRelatedProjects := Nil,
tlSiteKeepFiles := true,
tlSiteJavaVersion := {
githubWorkflowJavaVersions
.value
.collectFirst {
case spec @ JavaSpec(_, version)
if version
.split('.')
.lift(0)
.flatMap(v => Try(v.toInt).toOption)
.exists(_ >= 11) =>
spec
}
.getOrElse(JavaSpec.temurin("11"))
},
homepage := {
gitHubUserRepo.value.map {
case ("typelevel", repo) => url(s"https://typelevel.org/$repo")
Expand Down Expand Up @@ -209,16 +226,25 @@ object TypelevelSitePlugin extends AutoPlugin {
List.empty
}
},
ThisBuild / githubWorkflowAddedJobs +=
ThisBuild / githubWorkflowAddedJobs += {

val extraJava =
if (!githubWorkflowJavaVersions.value.contains(tlSiteJavaVersion.value))
WorkflowStep.SetupJava(List(tlSiteJavaVersion.value))
else Nil

WorkflowJob(
"site",
"Generate Site",
scalas = List.empty,
sbtStepPreamble = List.empty,
javas = List(githubWorkflowJavaVersions.value.head),
steps =
githubWorkflowJobSetup.value.toList ++ tlSiteGenerate.value ++ tlSitePublish.value
javas = List(tlSiteJavaVersion.value),
steps = githubWorkflowJobSetup.value.toList ++
extraJava ++
tlSiteGenerate.value ++
tlSitePublish.value
)
}
)

private def previewTask = Def
Expand Down

0 comments on commit 2ef6dd0

Please sign in to comment.