Skip to content

Commit

Permalink
verup now add to commit version file
Browse files Browse the repository at this point in the history
  • Loading branch information
andgineer committed Aug 12, 2021
1 parent 09e2a2d commit 8cce61e
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions verup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,51 @@
# Increments version git tag
# Saves it into VERSION_FILE

VERSION_FILE="bombard/version.py"
VERSION_FILES=("bombard/version.py")

TAG=$(git describe --tags)

major=0
minor=0
build=0

regex="v\.([0-9]+)\.([0-9]+)\.([0-9]+)"
regex="v([0-9]+)\.([0-9]+)\.([0-9]+)"
if [[ $TAG =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
build="${BASH_REMATCH[3]}"
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
build="${BASH_REMATCH[3]}"
fi

echo -e "Last version: \033[33m$major.$minor.$build\033[39m"

if [[ $(git diff-index HEAD) || $(git status) == *"is ahead"* ]]; then
echo -e "\n\033[33mPlease commit and push all changes" \
"before setting version tag\033[39m\n"
exit -1
echo -e "\n\033[33mPlease commit and push all changes" \
"before setting version tag\033[39m\n"
exit -1
fi

if [[ "$1" == "release" ]]; then
build=0
minor=0
major=$(echo $major + 1 | bc)
build=0
minor=0
major=$(echo $major + 1 | bc)
elif [[ "$1" == "feature" ]]; then
build=0
minor=$(echo $minor + 1 | bc)
build=0
minor=$(echo $minor + 1 | bc)
elif [[ "$1" == "bug" ]]; then
build=$(echo $build + 1 | bc)
build=$(echo $build + 1 | bc)
else
echo "usage: ./verup.sh [release|feature|bug]"
exit -1
echo "usage: ./verup.sh [release|feature|bug]"
exit -1
fi

NEW_TAG=$(echo "v.$major.$minor.$build")
NEW_VERSION=$(echo "$major.$minor.$build")
NEW_TAG=$(echo "v$NEW_VERSION")
echo -e "New version tag: \033[32m$NEW_TAG\033[39m"
echo -e "VERSION = '$major.$minor.$build'" > $VERSION_FILE

for file in ${VERSION_FILES[*]}; do
echo -e "VERSION = '$NEW_VERSION'" >$file
git add $file
done

COMMIT_MSG=$(git log $TAG..HEAD --format=oneline | awk '{$1=""; print $0}')
COMMIT_MSG=$(echo -e "\n$COMMIT_MSG\n")
Expand All @@ -54,6 +59,6 @@ git add $VERSION_FILE
git commit -m "Version $NEW_TAG$COMMIT_MSG"

echo "...push"
git tag $NEW_TAG -m "$COMMIT_MSG"
git push origin $NEW_TAG
git push
git tag $NEW_TAG -m "$COMMIT_MSG"
git push origin $NEW_TAG
git push

0 comments on commit 8cce61e

Please sign in to comment.