Skip to content

Commit 80a96c7

Browse files
authored
Add latest unstable release to docsite (#5148)
This isn't stored in any tag in the Git repo, so we need to fetch it from Maven Central's `maven-metadata.xml` in an input task I also broke up the `oldDocSources` into multiple smaller tasks using a `Cross` module, so we can get some parallelism on what is typically a pretty slow code path
1 parent 726f92a commit 80a96c7

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

build.mill

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ def millVersion: T[String] = Task {
4545
} else "SNAPSHOT"
4646
}
4747

48-
def millLastTagTruth: T[String] = Task {
49-
VcsVersion.calcVcsState(Task.log).lastTag.getOrElse(
50-
sys.error("No (last) git tag found. Your git history seems incomplete!")
51-
)
48+
def latestUnstableVersion = Task.Input {
49+
val mavenMetadataXml = requests
50+
.get("https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/maven-metadata.xml")
51+
.text()
52+
53+
val xml = scala.xml.XML.loadString(mavenMetadataXml)
54+
55+
(xml \\ "version").map(_.text).last
5256
}
5357

5458
def millLastTag: T[String] = Task {

website/docs/modules/ROOT/pages/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Mill: A Better JVM Build Tool
22

33
https://github.com/com-lihaoyi/mill/blob/main/changelog.adoc[image:https://img.shields.io/maven-central/v/com.lihaoyi/mill-dist?label=stable-version&versionPrefix={mill-version}&versionSuffix={mill-version}[d]]
4-
https://central.sonatype.com/artifact/com.lihaoyi/mill-dist[image:https://img.shields.io/maven-central/v/com.lihaoyi/mill-dist?label=unstable-version&versionPrefix=0.12.[Maven Central Version]]
4+
https://central.sonatype.com/artifact/com.lihaoyi/mill-dist[image:https://img.shields.io/maven-central/v/com.lihaoyi/mill-dist?label=unstable-dev-version[Maven Central Version]]
55

66
Mill is a JVM build tool that supports Java, Scala, and Kotlin:
77

website/package.mill

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,39 +299,68 @@ object `package` extends mill.Module {
299299
|""".stripMargin
300300
}
301301

302-
def oldDocSources: T[Seq[PathRef]] = Task {
303-
val versionLabels =
304-
Settings.docTags.map { v =>
305-
(v, v.split('.').dropRight(1).mkString(".") + ".x")
306-
}.dropRight(1) ++
307-
// Set the latest stable branch as the "master" docs that people default to
308-
Seq((Settings.docTags.last, "master"))
309-
310-
for ((millVersion, antoraVersion) <- versionLabels) yield {
302+
val versionLabels =
303+
Settings.docTags.map { v =>
304+
(v, v, v, v.split('.').dropRight(1).mkString(".") + ".x", false)
305+
}.dropRight(1) ++
306+
// Set the latest stable branch as the "master" docs that people default to
307+
Seq(
308+
(Settings.docTags.last, Settings.docTags.last, Settings.docTags.last, "master", false),
309+
("dev", "dev", "dev", "dev", true)
310+
)
311+
312+
def oldDocSources = Task {
313+
Task.traverse(oldDocs.items.map(_.module))(_.value.oldDocSource)()
314+
}
315+
316+
object oldDocs extends Cross[OldDocModule](versionLabels)
317+
trait OldDocModule extends Cross.Module5[String, String, String, String, Boolean] {
318+
319+
def oldDocSource: T[PathRef] = Task {
320+
val millVersion =
321+
if (crossValue == "dev") build.latestUnstableVersion()
322+
else crossValue
323+
324+
val gitVersion =
325+
if (crossValue2 == "dev") build.latestUnstableVersion().split('-').last
326+
else crossValue2
327+
328+
val displayVersion =
329+
if (crossValue3 == "dev") "dev-" + build.latestUnstableVersion()
330+
else crossValue3
331+
332+
val antoraVersion = if (crossValue4 == "dev") displayVersion else crossValue4
333+
334+
val newWebsiteTask: Boolean = crossValue5
335+
311336
val checkout = Task.dest / millVersion
312337
os.proc("git", "clone", Task.workspace / ".git", checkout).call(stdout = os.Inherit)
313-
os.proc("git", "checkout", millVersion).call(cwd = checkout, stdout = os.Inherit)
314-
val outputFolder = checkout / "out/docs/source.dest"
315-
os.proc("./mill", "-i", "docs.source").call(cwd = checkout, stdout = os.Inherit)
338+
os.proc("git", "checkout", gitVersion).call(cwd = checkout, stdout = os.Inherit)
339+
val outputFolder = if (newWebsiteTask) {
340+
os.proc("./mill", "-i", "website.source").call(cwd = checkout, stdout = os.Inherit)
341+
checkout / "out/website/source.dest"
342+
} else {
343+
os.proc("./mill", "-i", "docs.source").call(cwd = checkout, stdout = os.Inherit)
344+
checkout / "out/docs/source.dest"
345+
}
346+
316347
expandDiagramsInDirectoryAdocFile(
317348
outputFolder,
318349
mill.main.VisualizeModule.toolsClasspath().map(_.path)
319350
)
320351

321-
val useOldDownloadUrl = Version.OsgiOrdering.lt(
322-
Version.parse(millVersion),
323-
Version.parse("0.12.6")
324-
)
352+
val useOldDownloadUrl =
353+
if (antoraVersion.startsWith("dev-")) false
354+
else Version.OsgiOrdering.lt(Version.parse(millVersion), Version.parse("0.12.6"))
325355

326356
val millDownloadUrl =
327357
if (useOldDownloadUrl) s"${Settings.projectUrl}/releases/download/$millVersion"
328358
else s"${build.millDownloadPrefix()}/$millVersion"
329359

330-
sanitizeAntoraYml(outputFolder, antoraVersion, millVersion, millVersion, millDownloadUrl)
360+
sanitizeAntoraYml(outputFolder, antoraVersion, displayVersion, millVersion, millDownloadUrl)
331361
PathRef(outputFolder)
332362
}
333363
}
334-
335364
def githubPages: T[PathRef] = Task {
336365
generatePages(authorMode = false).apply().apply(oldDocSources().map(_.path))
337366
}

0 commit comments

Comments
 (0)