Skip to content

Commit

Permalink
[skip-ci] version: Improve reading version
Browse files Browse the repository at this point in the history
  • Loading branch information
oreiche committed Apr 10, 2024
1 parent f9142da commit 99622f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/just-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions .github/make-pkg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 99622f8

Please sign in to comment.