Skip to content

Commit

Permalink
Merge pull request #97 from armanbilge/feature/tlsite-task
Browse files Browse the repository at this point in the history
Make site plugin more robust
  • Loading branch information
armanbilge authored Jan 23, 2022
2 parents 62914d2 + ee9f775 commit fbac902
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Generate site
run: sbt '++${{ matrix.scala }}' tlSite
run: sbt '++${{ matrix.scala }}' docs/tlSite

- name: Publish site
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
Expand Down
16 changes: 13 additions & 3 deletions site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.typelevel.sbt.kernel.GitHelper
import gha.GenerativePlugin, GenerativePlugin.autoImport._
import scala.io.Source
import java.util.Base64
import scala.annotation.nowarn

object TypelevelSitePlugin extends AutoPlugin {

Expand All @@ -39,10 +40,10 @@ object TypelevelSitePlugin extends AutoPlugin {
"A sequence of workflow steps which publishes the site (default: peaceiris/actions-gh-pages)")
lazy val tlSitePublishBranch = settingKey[Option[String]](
"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)")
lazy val tlSite = taskKey[Unit]("Generate the site (default: runs mdoc then laika)")
}

import autoImport._
import TypelevelKernelPlugin.mkCommand

override def requires = MdocPlugin && LaikaPlugin && GenerativePlugin && NoPublishPlugin

Expand All @@ -52,6 +53,12 @@ object TypelevelSitePlugin extends AutoPlugin {
)

override def projectSettings = Seq(
tlSite := Def
.sequential(
mdoc.toTask(""),
laikaSite
)
.value: @nowarn("cat=other-pure-statement"),
Laika / sourceDirectories := Seq(mdocOut.value),
laikaTheme := tlSiteHeliumConfig.value.build,
mdocVariables ++= Map(
Expand Down Expand Up @@ -105,7 +112,10 @@ object TypelevelSitePlugin extends AutoPlugin {
laika.parse.code.SyntaxHighlighting
),
tlSiteGenerate := List(
WorkflowStep.Sbt(List("tlSite"), name = Some("Generate site"))
WorkflowStep.Sbt(
List(s"${thisProject.value.id}/${tlSite.key.toString}"),
name = Some("Generate site")
)
),
tlSitePublish := List(
WorkflowStep.Use(
Expand Down Expand Up @@ -140,7 +150,7 @@ object TypelevelSitePlugin extends AutoPlugin {
steps =
githubWorkflowJobSetup.value.toList ++ tlSiteGenerate.value ++ tlSitePublish.value
)
) ++ addCommandAlias("tlSite", mkCommand(List("docs/mdoc", "docs/laikaSite")))
)

private def getSvgLogo: String = {
val src = Source.fromURL(getClass.getResource("/logo.svg"))
Expand Down

0 comments on commit fbac902

Please sign in to comment.