Merge pull request #3519 from crazy-max/fix-version-quad-2

fix version quad logic that trims 0 digit so returns an empty one
This commit is contained in:
Sebastiaan van Stijn 2022-03-31 22:56:15 +02:00 committed by GitHub
commit c23d45f0c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 8 deletions

View File

@ -3,14 +3,19 @@ set -eu
: "${PACKAGER_NAME=}" : "${PACKAGER_NAME=}"
quadVersionNum() {
num=$(echo "${1:-0}" | cut -d. -f"$2")
if [ "$num" != "0" ]; then
echo "${num#0}"
else
echo "$num"
fi
}
. ./scripts/build/.variables . ./scripts/build/.variables
# Create version quad for Windows of the form major.minor.patch.build # Create version quad for Windows of the form major.minor.patch.build
VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | sed -re 's/\.$//' | sed -re 's/^[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+\.[0-9]+$/\0\.0/') VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | sed -re 's/\.$//' | sed -re 's/^[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+\.[0-9]+$/\0\.0/')
VERSION_MAJOR=$(echo "${VERSION_QUAD:-0}" | cut -d. -f1)
VERSION_MINOR=$(echo "${VERSION_QUAD:-0}" | cut -d. -f2)
VERSION_PATCH=$(echo "${VERSION_QUAD:-0}" | cut -d. -f3)
VERSION_BUILD=$(echo "${VERSION_QUAD:-0}" | cut -d. -f4)
# Generate versioninfo.json to be able to create a syso file which contains # Generate versioninfo.json to be able to create a syso file which contains
# Microsoft Windows Version Information and an icon using goversioninfo. # Microsoft Windows Version Information and an icon using goversioninfo.
@ -21,10 +26,10 @@ cat > ./cli/winresources/versioninfo.json <<EOL
"FixedFileInfo": "FixedFileInfo":
{ {
"FileVersion": { "FileVersion": {
"Major": ${VERSION_MAJOR}, "Major": $(quadVersionNum "$VERSION_QUAD" 1),
"Minor": ${VERSION_MINOR#0}, "Minor": $(quadVersionNum "$VERSION_QUAD" 2),
"Patch": ${VERSION_PATCH}, "Patch": $(quadVersionNum "$VERSION_QUAD" 3),
"Build": ${VERSION_BUILD} "Build": $(quadVersionNum "$VERSION_QUAD" 4)
}, },
"FileFlagsMask": "3f", "FileFlagsMask": "3f",
"FileFlags ": "00", "FileFlags ": "00",