From 1eb5694459beb4fa7d9639683f4670f00d9c5278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Pitu=C5=82a?= Date: Thu, 6 Aug 2026 10:53:17 +0200 Subject: [PATCH] Extract website version from a file instead of sbt stdout sbt's stdout is not machine-readable: even with -error and --no-colors it emits terminal erase-in-display sequences (ESC[0J) from the progress display, plus the [success] line. Parsing it with `head -n 1` produced a version like "\e[0J0.2.3", which rendered as "[0J0.2.3" on the website. Add a `writeStableVersion` task that writes `stableVersion` to target/stable-version.txt and have the workflow read that file, removing the stdout parsing and the warm-up sbt invocation it required. --- .github/workflows/website-deploy.yml | 7 +++++-- build.sbt | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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(