From 99622f846330e33362c8731c4b633ff2e0c706ce Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Wed, 10 Apr 2024 20:30:19 +0200 Subject: [PATCH] [skip-ci] version: Improve reading version --- .github/just-version.sh | 4 ++-- .github/make-pkg/build.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/just-version.sh b/.github/just-version.sh index a6aa2bee..159bc508 100755 --- a/.github/just-version.sh +++ b/.github/just-version.sh @@ -5,11 +5,11 @@ set -euo pipefail readonly VERSION_FILE=$(cat ./src/buildtool/main/version.cpp) function get_size() { - echo "$VERSION_FILE" | sed -n 's/\s*std::size_t\s'$1'\s=\s\([0-9]\+\);$/\1/p' + echo "$VERSION_FILE" | sed -n 's/\s*std::size_t\s'$1'\s=\s\([0-9]\+\);.*$/\1/p' } function get_string() { - echo "$VERSION_FILE" | sed -n 's/\s*std::string\s'$1'\s=.*\"\(.*\)\".*;$/\1/p' + echo "$VERSION_FILE" | sed -n 's/\s*std::string\s'$1'\s=.*\"\(.*\)\".*;.*$/\1/p' } readonly MAJOR=$(get_size major) diff --git a/.github/make-pkg/build.sh b/.github/make-pkg/build.sh index 1256d3c6..810201d9 100755 --- a/.github/make-pkg/build.sh +++ b/.github/make-pkg/build.sh @@ -29,10 +29,10 @@ git archive ${REF} | tar -x -C "${SRCDIR}" # obtain version VERSION_FILE="${SRCDIR}/src/buildtool/main/version.cpp" -MAJOR=$(cat ${VERSION_FILE} | sed -n 's/\s*std::size_t\smajor\s=\s\([0-9]\+\);$/\1/p') -MINOR=$(cat ${VERSION_FILE} | sed -n 's/\s*std::size_t\sminor\s=\s\([0-9]\+\);$/\1/p') -PATCH=$(cat ${VERSION_FILE} | sed -n 's/\s*std::size_t\srevision\s=\s\([0-9]\+\);$/\1/p') -SUFFIX=$(cat ${VERSION_FILE} | sed -n 's/\s*std::string\ssuffix\s=.*\"\(.*\)\".*;$/\1/p') +MAJOR=$(cat ${VERSION_FILE} | sed -n 's/\s*std::size_t\smajor\s=\s\([0-9]\+\);.*$/\1/p') +MINOR=$(cat ${VERSION_FILE} | sed -n 's/\s*std::size_t\sminor\s=\s\([0-9]\+\);.*$/\1/p') +PATCH=$(cat ${VERSION_FILE} | sed -n 's/\s*std::size_t\srevision\s=\s\([0-9]\+\);.*$/\1/p') +SUFFIX=$(cat ${VERSION_FILE} | sed -n 's/\s*std::string\ssuffix\s=.*\"\(.*\)\".*;.*$/\1/p') VERSION="$MAJOR.$MINOR.$PATCH" if [ -n "$SUFFIX" ]; then VERSION="$VERSION$SUFFIX"