#!/bin/bash

set -eu

if ! [ $# -eq 1 ] ; then
    echo "usage: ./bin/release [version]"
    exit 1
fi

VERSION=$1

if ! git diff-index --quiet HEAD -- ; then
    echo "uncommited changes on HEAD, aborting"
    exit 1
fi

if [[ ${VERSION:0:1} != "v" ]] ; then
    echo "version strings must start with v"
    exit 1
fi

git fetch origin
git checkout origin/master

git tag -a $VERSION -m $VERSION
git push origin $VERSION
git push origin HEAD:master


echo "Now go write some release notes! https://github.com/vektah/gqlparser/releases"
