From 0e9cf861f41dc7fb2ce0cc411896d5ff78838566 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Tue, 23 Aug 2022 23:43:25 +0200
Subject: [PATCH] CI: fix getting-the-version in release script

---
 ci/RELEASE.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/ci/RELEASE.sh b/ci/RELEASE.sh
index 2d7d9a559d..fe2bc173be 100755
--- a/ci/RELEASE.sh
+++ b/ci/RELEASE.sh
@@ -86,6 +86,16 @@ KEY_ID="328D742D8807A435"
 rm -f CMakeLists.txt.gpg
 gpg -s -u $KEY_ID CMakeLists.txt
 
+### Get version number for this release
+#
+# Do this early, in a clean build-dir, since it doesn't cost much.
+# Redirect stderr from CMake script mode, because the message()
+# in CMakeLists.txt that prints the version, goes to stderr.
+rm -rf "$BUILDDIR"
+mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; }
+V=$( cd "$BUILDDIR" && cmake -P ../CMakeLists.txt 2>&1 )
+test -n "$V" || { echo "Could not obtain version in $BUILDDIR ." ; exit 1 ; }
+
 ### Build with default compiler
 #
 #
@@ -124,12 +134,6 @@ else
     ( cd "$BUILDDIR" && cmake .. ) || { echo "Could not run cmake in $BUILDDIR ." ; exit 1 ; }
 fi
 
-### Get version number for this release
-#
-#
-V=$( cd "$BUILDDIR" && cmake -P ../CMakeLists.txt | grep ^CALAMARES_VERSION | sed s/^[A-Z_]*=// )
-test -n "$V" || { echo "Could not obtain version in $BUILDDIR ." ; exit 1 ; }
-
 ### Create signed tag
 #
 # This is the signing key ID associated with the GitHub account adriaandegroot,
-- 
GitLab