#!/bin/bash

# update the version information in setup.py to the current git tag
# this should only be called during a CI build
# do NOT commit any version other than 0.0.0 in setup.py

TAGS=$(git describe --all --tags)

TAG=${TAGS##*/}

if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)[a-zA-Z]*$ ]]; then
	echo "Not a version tag"
	exit 1
fi

VERSION=${TAG#v}

sed -i s/0.0.0/${VERSION}/ setup.py
