#!/bin/sh

PARENT_VERSION=$(cat pom.xml | tr '\n' ' ' | grep -o "<parent>.*</parent>" | grep -o "<version>.*</version>")
if [ -z "$PARENT_VERSION" ]; then
  VERSIONS=$(grep "<version>" pom.xml | head -n 1 | cut -d '>' -f2 | cut -d '<' -f1)
else
  VERSIONS=$(grep "<version>" pom.xml | head -n 2 | grep -v "$PARENT_VERSION" | cut -d '>' -f2 | cut -d '<' -f1)
fi
STR="$VERSIONS"
MIDDLE=$(echo "$VERSIONS" | cut -d '.' -f2)
if $(echo $MIDDLE | grep '^[0-9]*$' > /dev/null) && [ $(($MIDDLE%2)) -eq 0 ]; then
  STR="$STR:release"
fi
echo "$STR"
