Skip to content

Commit

Permalink
Update version bump script
Browse files Browse the repository at this point in the history
  • Loading branch information
direc85 committed Mar 6, 2022
1 parent e3f7498 commit 5409e3a
Showing 1 changed file with 42 additions and 21 deletions.
63 changes: 42 additions & 21 deletions update-spec-version.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
#!/bin/bash
set -e

SPEC=rpm/$1.spec
CPP=src/main.cpp
# Parse the project file, target name, version and release
PRO=$(ls *.pro | head -1)
NAME=$(grep -e "TARGET *= *" $PRO | sed "s/TARGET *= *//g")
VER=$(grep -e "VER *= *" $PRO | sed "s/VER *= *//g")
REL=$(grep -e "REL *= *" $PRO | sed "s/REL *= *//g")

if [[ $(grep "^Version: $2$" $SPEC | wc -l) = 0 ]]
then
sed -i "/^Version: /c\Version: $2" $SPEC
touch $CPP
fi
if [[ $(grep "^Release: $3$" $SPEC | wc -l) = 0 ]]
then
sed -i "/^Release: /c\Release: $3" $SPEC
touch $CPP
SPEC=rpm/$NAME.spec
YAML=rpm/$NAME.yaml
CPP=src/$NAME.cpp

if [ ! -f $CPP ]; then
CPP=src/main.cpp
if [ ! -f $CPP ]; then
echo "Main C++ file not found!"
exit 1
fi
fi

echo "$NAME $VER-$REL"

YAML=rpm/$1.yaml
if [[ $(grep "^Version: $2$" $YAML | wc -l) = 0 ]]
then
sed -i "/^Version: /c\Version: $2" $YAML
touch $CPP
if [[ -f $SPEC && ($(grep "^Version: $VER$" $SPEC | wc -l) == 0 || $(grep "^Release: $REL$" $SPEC | wc -l) == 0) ]]; then
sed -i "/^Version: /c\Version: $VER" $SPEC
sed -i "/^Release: /c\Release: $REL" $SPEC
echo " $SPEC updated"
elif [[ ! -f $SPEC ]]; then
echo " .spec file not found"
else
echo " $SPEC up to date"
fi
if [[ $(grep "^Release: $3$" $YAML | wc -l) = 0 ]]
then
sed -i "/^Release: /c\Release: $3" $YAML
touch $CPP

if [[ -f $YAML && ($(grep "^Version: $VER$" $YAML | wc -l) == 0 || $(grep "^Release: $REL$" $YAML | wc -l) == 0) ]]; then
sed -i "/^Version: /c\Version: $VER" $YAML
sed -i "/^Release: /c\Release: $REL" $YAML
echo " $YAML updated"
elif [[ ! -f $YAML ]]; then
echo " .yaml file not found"
else
echo " $YAML up to date"
fi

if [[ -f $CPP ]]; then
touch $CPP
echo " $CPP touched"
else
echo " .cpp file not found"
fi

echo true
exit 0

0 comments on commit 5409e3a

Please sign in to comment.