Skip to content

Commit

Permalink
Use git tags over last merge to get last version number.
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Maher <[email protected]>
  • Loading branch information
bmaher committed May 21, 2019
1 parent 9b380b6 commit ae94636
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions check_version.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#! /bin/bash

LAST_MERGE=$(git log --pretty="format:%H" --merges -n 1)
VERSION_FILE="pyproject.toml"
PREVIOUS_VERSION=$(git show $LAST_MERGE:$VERSION_FILE | grep version | awk '{print $3}')
CURRENT_VERSION=$(grep -m 1 version $VERSION_FILE | awk '{print $3}')
PREVIOUS_VERSION=$(git describe --abbrev=0 --tags)
# Remove leading 'v' char.
PREVIOUS_VERSION=${PREVIOUS_VERSION#?}
# Using sed to remove leading and trailing double quotes.
CURRENT_VERSION=$(grep -m 1 version $VERSION_FILE | awk '{print $3}' | sed -e 's/^"//' -e 's/"$//')

if [ $CURRENT_VERSION == $PREVIOUS_VERSION ]; then
echo "ERROR: Version has not been updated in '$VERSION_FILE'!"
Expand Down

0 comments on commit ae94636

Please sign in to comment.