#!/bin/bash

VERSION="$(cat project.clj | egrep -o -m 1 '[0-9].[0-9].[0-9](-[A-Z]+)?')"

echo "VERSION: $VERSION"

if [[ $VERSION =~ "SNAPSHOT" ]];
then
    echo "Skipping tagging..."
    exit 0;
fi

lein pom

./node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s
git add CHANGELOG.md pom.xml
git commit -q -m "chore(release): Version ${VERSION} :tada: [skip ci]

$(./node_modules/.bin/conventional-changelog -p angular)
"

git push

git tag ${VERSION}

git push origin ${VERSION}
