#!/usr/bin/env bash
set -euo pipefail

scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

version_next=$(cat version-next)

case $# in
    0) part=patch;;
    1) part=$1;;
    *) echo "Too many args: $*"; exit 1;;
esac

new_version="$(${scripts}/semver.sh bump $part $version_next)"

echo "old version: $version_next"
echo "new version: $new_version"
echo "$new_version" > version-next
