From bb42a049a9445ae584acc5ee85ec59d2440c3689 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sat, 25 Jul 2020 13:55:37 +1000 Subject: [PATCH] Close #165 - Replace sbt-microsites with Docusaurus --- .github/workflows/publish-github-pages.yml | 85 ++++++++------ README.md | 5 +- build.sbt | 122 ++++++++++++--------- project/plugins.sbt | 2 + website/static/CNAME | 1 + 5 files changed, 125 insertions(+), 90 deletions(-) create mode 100644 website/static/CNAME diff --git a/.github/workflows/publish-github-pages.yml b/.github/workflows/publish-github-pages.yml index 825b422..31d9256 100644 --- a/.github/workflows/publish-github-pages.yml +++ b/.github/workflows/publish-github-pages.yml @@ -10,38 +10,55 @@ jobs: runs-on: ubuntu-latest + strategy: + matrix: + scala: + - { version: "2.13.3", binary-version: "2.13", java-version: "11" } + steps: - - uses: actions/checkout@v1 - - - name: Cache Coursier - uses: actions/cache@v1 - with: - path: ~/.cache/coursier - key: ${{ runner.os }}-coursier-scala-2_13-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }} - restore-keys: | - ${{ runner.os }}-coursier-scala-2_13- - - - name: Cache Ivy - uses: actions/cache@v1 - with: - path: ~/.ivy2/cache - key: ${{ runner.os }}-ivy-scala-2_13-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }} - restore-keys: | - ${{ runner.os }}-ivy-scala-2_13- - - - name: publish GitHub Pages - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_AUTH_TOKEN }} - run: | - docker run \ - -e GITHUB_TOKEN=$GITHUB_TOKEN \ - -v ${{ github.workspace }}:/app \ - -v ~/.cache/coursier:/root/.cache/coursier:z \ - -v ~/.ivy2/cache:/root/.ivy2/cache:z \ - k3vin/sbt-java8-jekyll:latest /bin/bash -c "cd /app && sbt 'project docs' clean publishMicrosite" - - - name: correct dir permission - run: | - sudo chown -R $(whoami):docker ~/.ivy2 - sudo chown -R $(whoami):docker ~/.cache - sudo chown -R $(whoami):docker ${{ github.workspace }} + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.scala.java-version }} + - uses: actions/setup-node@v1 + with: + node-version: '14.4.0' + registry-url: 'https://registry.npmjs.org' + + - name: Cache Coursier + uses: actions/cache@v1 + with: + path: ~/.cache/coursier + key: ${{ runner.os }}-coursier-scala-${{ matrix.scala.binary-version }}-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }} + restore-keys: | + ${{ runner.os }}-coursier-scala-${{ matrix.scala.binary-version }}- + + - name: Cache Ivy + uses: actions/cache@v1 + with: + path: ~/.ivy2/cache + key: ${{ runner.os }}-ivy-scala-${{ matrix.scala.binary-version }}-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }} + restore-keys: | + ${{ runner.os }}-ivy-scala-${{ matrix.scala.binary-version }}- + + - name: Cache npm + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Build and publish website + env: + ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} + ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + sbt clean \ + docs/mdoc \ + docs/docusaurGenerateAlgoliaConfigFile \ + docs/docusaurInstall \ + docs/docusaurCleanBuild \ + docs/docusaurBuild \ + docs/publishToGitHubPages diff --git a/README.md b/README.md index a91a78e..50d1986 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,4 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.kevinlee/just-fp_2.13/badge.svg)](https://search.maven.org/artifact/io.kevinlee/just-fp_2.13) [![Latest version](https://index.scala-lang.org/kevin-lee/just-fp/just-fp/latest.svg)](https://index.scala-lang.org/kevin-lee/just-fp/just-fp) - -A small Functional Programming library. This is not meant to be an alternative to Scalaz or Cats. The reason for having this library is that in your project you don't want to have Scalaz or Cats as its dependency and you only need much smaller set of functional programming features than what Scalaz or Cats offers. So the users of your library can choose Scalaz or Cats to be used with your library. - -Please visit the [homepage](https://kevin-lee.github.io/just-fp) for more details. +# Please visit [https://kevin-lee.github.io/just-fp](https://kevin-lee.github.io/just-fp) diff --git a/build.sbt b/build.sbt index cd6e9f0..c344172 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,11 @@ import microsites.ConfigYml val ProjectScalaVersion: String = "2.13.1" val CrossScalaVersions: Seq[String] = Seq("2.10.7", "2.11.12", "2.12.11", ProjectScalaVersion) -def prefixedProjectName(name: String) = s"just-fp${if (name.isEmpty) "" else s"-$name"}" +val GitHubUsername = "Kevin-Lee" +val RepoName = "just-fp" +val ProjectName = RepoName + +def prefixedProjectName(name: String) = s"$ProjectName${if (name.isEmpty) "" else s"-$name"}" lazy val noPublish = Seq( publish := {}, @@ -31,24 +35,15 @@ ThisBuild / scalaVersion := ProjectScalaVersion ThisBuild / version := ProjectVersion ThisBuild / organization := "io.kevinlee" ThisBuild / developers := List( - Developer("Kevin-Lee", "Kevin Lee", "kevin.code@kevinlee.io", url("https://github.com/Kevin-Lee")) + Developer(GitHubUsername, "Kevin Lee", "kevin.code@kevinlee.io", url(s"https://github.com/$GitHubUsername")) ) -ThisBuild / homepage := Some(url("https://github.com/Kevin-Lee/just-fp")) +ThisBuild / homepage := Some(url(s"https://github.com/$GitHubUsername/$RepoName")) ThisBuild / scmInfo := Some(ScmInfo( - url("https://github.com/Kevin-Lee/just-fp") - , "git@github.com:Kevin-Lee/just-fp.git" + url(s"https://github.com/$GitHubUsername/$RepoName") + , s"git@github.com:$GitHubUsername/$RepoName.git" )) -lazy val justFp = (project in file(".")) - .enablePlugins(DevOopsGitReleasePlugin) - .settings( - name := prefixedProjectName("") - , description := "Just FP Lib" - ) - .settings(noPublish) - .aggregate(core, docs) - lazy val core = (project in file("core")) .enablePlugins(DevOopsGitReleasePlugin) .settings( @@ -114,7 +109,7 @@ lazy val core = (project in file("core")) , testFrameworks ++= Seq(TestFramework("hedgehog.sbt.Framework")) /* Bintray { */ , bintrayPackageLabels := Seq("Scala", "Functional Programming", "FP") - , bintrayVcsUrl := Some("""git@github.com:Kevin-Lee/just-fp.git""") + , bintrayVcsUrl := Some(s"""git@github.com:$GitHubUsername/$RepoName.git""") , licenses += ("MIT", url("http://opensource.org/licenses/MIT")) /* } Bintray */ @@ -131,45 +126,68 @@ lazy val core = (project in file("core")) /* } Coveralls */ ) -lazy val docDir = file("docs") -lazy val docs = (project in docDir) - .enablePlugins(MicrositesPlugin) - .settings(noPublish) - .settings( - name := prefixedProjectName("docs") - /* microsites { */ - , micrositeName := prefixedProjectName("") - , micrositeAuthor := "Kevin Lee" - , micrositeHomepage := "https://blog.kevinlee.io" - , micrositeDescription := "Just FP" - , micrositeGithubOwner := "Kevin-Lee" - , micrositeGithubRepo := "just-fp" - , micrositeBaseUrl := "/just-fp" - , micrositeDocumentationUrl := s"${micrositeBaseUrl.value}/docs" - , micrositePushSiteWith := GitHub4s - , micrositeGithubToken := sys.env.get("GITHUB_TOKEN") -// , micrositeTheme := "pattern" - , micrositeHighlightTheme := "atom-one-light" - , micrositeGitterChannel := false - , micrositeGithubLinks := false - , micrositeShareOnSocial := false - , micrositeHighlightLanguages ++= Seq("shell") +//lazy val docDir = file("docs") +//lazy val docs = (project in docDir) +// .enablePlugins(MicrositesPlugin) +// .settings(noPublish) +// .settings( +// name := prefixedProjectName("docs") +// /* microsites { */ +// , micrositeName := prefixedProjectName("") +// , micrositeAuthor := "Kevin Lee" +// , micrositeHomepage := "https://blog.kevinlee.io" +// , micrositeDescription := "Just FP" +// , micrositeGithubOwner := "Kevin-Lee" +// , micrositeGithubRepo := "just-fp" +// , micrositeBaseUrl := "/just-fp" +// , micrositeDocumentationUrl := s"${micrositeBaseUrl.value}/docs" +// , micrositePushSiteWith := GitHub4s +// , micrositeGithubToken := sys.env.get("GITHUB_TOKEN") +//// , micrositeTheme := "pattern" +// , micrositeHighlightTheme := "atom-one-light" +// , micrositeGitterChannel := false +// , micrositeGithubLinks := false +// , micrositeShareOnSocial := false +// , micrositeHighlightLanguages ++= Seq("shell") +// +// , micrositeConfigYaml := ConfigYml( +// yamlPath = Some(docDir / "microsite" / "_config.yml") +// ) +// , micrositeImgDirectory := docDir / "microsite" / "img" +// , micrositeCssDirectory := docDir / "microsite" / "css" +// , micrositeSassDirectory := docDir / "microsite" / "sass" +// , micrositeJsDirectory := docDir / "microsite" / "js" +// , micrositeExternalLayoutsDirectory := docDir / "microsite" / "layouts" +// , micrositeExternalIncludesDirectory := docDir / "microsite" / "includes" +// , micrositeDataDirectory := docDir / "microsite" / "data" +// , micrositeStaticDirectory := docDir / "microsite" / "static" +// , micrositeExtraMdFilesOutput := docDir / "microsite" / "extra_md" +// , micrositePluginsDirectory := docDir / "microsite" / "plugins" +// +// /* } microsites */ +// +// ) +// .dependsOn(core) - , micrositeConfigYaml := ConfigYml( - yamlPath = Some(docDir / "microsite" / "_config.yml") - ) - , micrositeImgDirectory := docDir / "microsite" / "img" - , micrositeCssDirectory := docDir / "microsite" / "css" - , micrositeSassDirectory := docDir / "microsite" / "sass" - , micrositeJsDirectory := docDir / "microsite" / "js" - , micrositeExternalLayoutsDirectory := docDir / "microsite" / "layouts" - , micrositeExternalIncludesDirectory := docDir / "microsite" / "includes" - , micrositeDataDirectory := docDir / "microsite" / "data" - , micrositeStaticDirectory := docDir / "microsite" / "static" - , micrositeExtraMdFilesOutput := docDir / "microsite" / "extra_md" - , micrositePluginsDirectory := docDir / "microsite" / "plugins" +lazy val docs = (project in file("generated-docs")) + .enablePlugins(MdocPlugin, DocusaurPlugin) + .settings( + name := prefixedProjectName("docs") - /* } microsites */ + , docusaurDir := (ThisBuild / baseDirectory).value / "website" + , docusaurBuildDir := docusaurDir.value / "build" + , gitHubPagesOrgName := GitHubUsername + , gitHubPagesRepoName := RepoName ) + .settings(noPublish) .dependsOn(core) + +lazy val justFp = (project in file(".")) + .enablePlugins(DevOopsGitReleasePlugin) + .settings( + name := prefixedProjectName("") + , description := "Just FP Lib" + ) + .settings(noPublish) + .aggregate(core, docs) diff --git a/project/plugins.sbt b/project/plugins.sbt index a5ef904..a34c2cb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -11,3 +11,5 @@ addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7") addSbtPlugin("io.kevinlee" % "sbt-devoops" % "1.0.3") addSbtPlugin("com.47deg" % "sbt-microsites" % "1.1.4") + +addSbtPlugin("io.kevinlee" % "sbt-docusaur" % "0.1.3") diff --git a/website/static/CNAME b/website/static/CNAME new file mode 100644 index 0000000..2166a4b --- /dev/null +++ b/website/static/CNAME @@ -0,0 +1 @@ +just-fp.kevinly.dev \ No newline at end of file