diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml index 0461cff..20ac3cf 100644 --- a/.github/workflows/website-deploy.yml +++ b/.github/workflows/website-deploy.yml @@ -45,8 +45,11 @@ jobs: - name: Build run: | cd ../ - sbt -batch -error 'print stableVersion' # something unexpected gets added to stdout on first run - export CHATOPS4S_VERSION=$(sbt -batch -error 'print stableVersion' | head -n 1) + # sbt stdout is not machine-readable (ANSI escapes, progress lines), so the + # version is written to a file by the build instead of being parsed from stdout. + sbt -batch writeStableVersion + export CHATOPS4S_VERSION=$(cat target/stable-version.txt) + echo "Building website for chatops4s $CHATOPS4S_VERSION" cd website yarn build - name: Setup Pages diff --git a/build.sbt b/build.sbt index df44ac9..6220f68 100644 --- a/build.sbt +++ b/build.sbt @@ -60,6 +60,18 @@ stableVersion := { else previousStableVersion.value.getOrElse("unreleased") } +lazy val stableVersionFile = settingKey[File]("File that writeStableVersion writes to") +stableVersionFile := (ThisBuild / baseDirectory).value / "target" / "stable-version.txt" + +// Writing to a file instead of printing, because sbt's stdout is not machine-readable +// (ANSI escapes, progress lines, launcher output). Consumed by the website build. +lazy val writeStableVersion = taskKey[Unit]("Writes stableVersion to stableVersionFile") +writeStableVersion := { + val target = stableVersionFile.value + IO.write(target, stableVersion.value) + streams.value.log.info(s"Wrote stable version to $target") +} + lazy val commonSettings = Seq( scalaVersion := "3.8.1", scalacOptions ++= Seq(