Skip to content

Commit

Permalink
fix: Only run if new version > old. regex fixes for ripgrep users.
Browse files Browse the repository at this point in the history
This patch will ensure that the regex portions run regardless of if the
user is running ripgrep or not.
This also adds checking that the new version is a higher version number
than the old number. Also nicer login for if this is the first run and
there have been no versions committed yet.
  • Loading branch information
Jacobomara901 authored and mblenk committed Jul 16, 2024
1 parent f8b9be8 commit 74daf0a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions release_kpz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RED="\033[0;31m"
NC="\033[0m" # No colour
GREEN="\033[0;32m"
YELLOW="\033[1;33m"

echo "Creating and releasing .kpz file"

Expand Down Expand Up @@ -30,10 +31,21 @@ else
NEW_VERSION_NUMBER=${NEW_VERSION:1}
fi

PREVIOUS_VERSION=$(git log --pretty=oneline | grep -P -m 1 -o "v[\d|.]{1,6}")
PREVIOUS_VERSION_NUMBER=${PREVIOUS_VERSION:1}
PREVIOUS_VERSION=$(git log --pretty=oneline | grep -m 1 -o "v[0-9.]\{1,6\}")
if [ -z "$PREVIOUS_VERSION" ]; then
echo -e "${YELLOW}No previous version found. Assuming this is the first release.${NC}"
PREVIOUS_VERSION_NUMBER="v0.0.0" # Assuming 0 as the initial version for comparison
else
PREVIOUS_VERSION_NUMBER=${PREVIOUS_VERSION:1}
fi
echo -e "Previous version: $PREVIOUS_VERSION"
echo -e "New version: $NEW_VERSION"

# Comparing versions
VERSION_COMPARISON=$(echo -e "$PREVIOUS_VERSION_NUMBER\n$NEW_VERSION_NUMBER" | sort -V | head -n 1)
echo -e "Version comparison: $VERSION_COMPARISON"

if [ "$NEW_VERSION_NUMBER" != "$PREVIOUS_VERSION_NUMBER" ]; then
if [ "$VERSION_COMPARISON" != "$PREVIOUS_VERSION_NUMBER" ]; then
echo -e "${GREEN}Version has been updated from $PREVIOUS_VERSION_NUMBER to $NEW_VERSION_NUMBER - checking remotes and starting upload${NC}"

REMOTES=$(git remote -v)
Expand Down

0 comments on commit 74daf0a

Please sign in to comment.