#!/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 info in setup.py

TAGS=$(git describe --all --tags)
TAG=${TAGS##*/}

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

VERSION=${TAG#v}

sed -i s/version=.*/version=\'${VERSION}\',/ setup.py
