Skip to content

Commit

Permalink
build: Version website (Iltotore#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore committed Jun 20, 2023
1 parent fc58d12 commit 9b3827c
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import $ivy.`io.chris-kipp::mill-ci-release::0.1.5`
import io.kipp.mill.ci.release.CiReleaseModule
import de.tobiasroeser.mill.vcs.version.VcsVersion

import mill._, define._

import mill._, define._, api.Result
import scalalib._, scalalib.scalafmt._, scalalib.publish._, scalajslib._, scalanativelib._

object versions {
Expand Down Expand Up @@ -69,10 +71,12 @@ trait BaseModule extends ScalaModule with ScalafmtModule with CiReleaseModule {
}
}

object docs extends ScalaModule {
object docs extends BaseModule {

def scalaVersion = versions.scala

def artifactName = "iron-docs"

val modules: Seq[ScalaModule] = Seq(main, cats, circe, jsoniter, scalacheck, zio, zioJson)

def docSources = T.sources {
Expand All @@ -83,11 +87,44 @@ object docs extends ScalaModule {
T.traverse(modules)(_.compileClasspath)().flatten
}

def docResources = T.sources { millSourcePath }
def docVersions = T.source {
val targetDir = T.dest / "_assets"

val versions =
os
.proc("git", "tag", "-l", "v*.*.*")
.call(VcsVersion.vcsBasePath)
.out
.trim()
.split("\n")
.map(_.substring(1))
.filterNot(_.contains("-RC"))
.reverse


def versionLink(version: String): String = {
val splat = version.split("\\.")
val (major, minor) = (splat(0).toInt, splat(1).toInt)
if(major >= 2 && minor >= 2) s"https://www.javadoc.io/doc/io.github.iltotore/iron-docs_3/$version/docs/index.html"
else s"https://www.javadoc.io/doc/io.github.iltotore/iron_3/$version/docs/index.html"
}

val links = versions.map(v => (v, ujson.Str(versionLink(v))))
val withNightly = links :+ ("Nightly", ujson.Str("https://iltotore.github.io/iron/docs/index.html"))
val json = ujson.Obj("versions" -> ujson.Obj.from(withNightly))

val versionsFile = targetDir / "versions.json"
os.write.over(versionsFile, ujson.write(json), createFolders = true)

T.dest
}

def docResources = T.sources(millSourcePath, docVersions().path)

def scalaDocOptions = Seq(
"-project", "Iron",
"-project-version", main.publishVersion(),
"-versions-dictionary-url", "versions.json",
s"-social-links:github::${main.pomSettings().url}"
)
}
Expand Down Expand Up @@ -185,6 +222,11 @@ trait SubModule extends BaseModule {

}

object sandbox extends SubModule {

def artifactName = "sandbox"
}

object cats extends SubModule {

def artifactName = "iron-cats"
Expand Down

0 comments on commit 9b3827c

Please sign in to comment.