#!/bin/sh

die () {
    echo $*
    echo "exiting..."
    exit 1
}

status=$(git status --short --untracked-files=no)

if [ "$status" != "" ]; then
    die "git working dir is not clean"
fi

if [ ! -e debian/changelog ]; then
    die "could not find debian/changelog"
fi

if [ "$1" = "" ]; then
    echo "usage: $0 <version>"
    exit 0
fi
version=$1
shift

set -e

EDITOR=/bin/true git dch --release --new-version $version
git add debian/changelog
git commit -m "debian package v$version"
git tag debian/$version
