diff --git a/build.sbt b/build.sbt index 8547c4e..2f2ed89 100644 --- a/build.sbt +++ b/build.sbt @@ -132,12 +132,20 @@ lazy val docs = project specularMetaProject := Some(LocalProject("hexis")), specularArtifactKind := "library", specularSiteDirectory := (ThisBuild / baseDirectory).value / "target" / "site", - // Do not strip -ci first. sbt-dynver-ci names a distance build 0.1.1-ci, and stripping - // that suffix yields 0.1.1, which is not the published coordinate. A raw version that - // contains -ci, +, or SNAPSHOT advertises the last Central tag. + // Chrome advertises the last published tag. Development version is the ship line + // plus -ci (0.1.1-ci). The docs workflow sets SPECULAR_STRIP_CI, and sbt-specular + // then ignores this setting and strips that suffix, which is not on Central. + // Update the string in the same commit that tags the next release. specularDisplayVersion := { raw => - val distance = raw.contains("-ci") || raw.contains("+") || raw.contains("SNAPSHOT") - if raw.nonEmpty && !distance then raw else "0.1.0" + val published = "0.1.0" + if raw.trim == published then published else published + }, + // The forked builder reads -Dspecular.meta.displayVersion. Replace the stripped + // ship line with this setting's result. + specularMetaProps := Def.uncached { + val published = specularDisplayVersion.value("") + val pinned = s"-Dspecular.meta.displayVersion=$published" + specularMetaProps.value.filterNot(_.startsWith("-Dspecular.meta.displayVersion=")) :+ pinned }, ) diff --git a/docs/src/test/scala/hexis/docs/DocsVersion.scala b/docs/src/test/scala/hexis/docs/DocsVersion.scala index 59bfd39..9ba632e 100644 --- a/docs/src/test/scala/hexis/docs/DocsVersion.scala +++ b/docs/src/test/scala/hexis/docs/DocsVersion.scala @@ -1,16 +1,14 @@ package hexis.docs -/** Install coordinate. Judge the raw build version. Do not trust a version after `-ci` was stripped. */ +/** Install coordinate. Always the last published tag. A bare next version is not on Central. */ object DocsVersion: - /** Last published tag. */ + /** Last published tag. Update this in the release commit. */ val published = "0.1.0" - /** A dynver distance (`-ci`, `+`, `SNAPSHOT`) is the next line. Anything else is advertised as written. */ + /** Returns [[published]]. A bare next version, `-ci`, `+`, and `SNAPSHOT` are unpublished. */ def advertise(raw: String): String = - val trimmed = raw.trim - val distance = trimmed.contains("-ci") || trimmed.contains("+") || trimmed.contains("SNAPSHOT") - if trimmed.nonEmpty && !distance then trimmed else published + if raw.trim == published then published else published /** `specular.meta.version` is the raw build version. Absent in unit tests, so those use [[published]]. */ def version: String = diff --git a/docs/src/test/scala/hexis/docs/Front.scala b/docs/src/test/scala/hexis/docs/Front.scala index c34b95f..eae069e 100644 --- a/docs/src/test/scala/hexis/docs/Front.scala +++ b/docs/src/test/scala/hexis/docs/Front.scala @@ -112,10 +112,10 @@ ${Install.coordinate} !Install.coordinate.contains("-ci"), !Install.coordinate.contains("SNAPSHOT"), !Install.coordinate.contains(""), + DocsVersion.advertise("0.1.1") == DocsVersion.published, DocsVersion.advertise("0.1.1-ci") == DocsVersion.published, - DocsVersion.advertise("0.1.1-SNAPSHOT") == DocsVersion.published, - DocsVersion.advertise("0.1.0+4-abcdef") == DocsVersion.published, - DocsVersion.advertise("0.1.0") == "0.1.0", + DocsVersion.advertise("0.1.0+1-abc") == DocsVersion.published, + DocsVersion.advertise(DocsVersion.published) == DocsVersion.published, ) }, test("the figure is evaluate, and fit keeps it inside a phone column") {