#!/usr/bin/env bash
if [[ $# != 1 ]]; then
    echo "Usage: ./release.sh <tag>" 1>&2
    echo 1>&2
    exit 1
fi

version_tag=$1
prefix=$(basename $(dirname $(which "$0")))
archive_name="${prefix}-${version_tag}.tar.gz"

rm -fv "${archive_name}"
echo "creating \`${archive_name}'"
git archive \
    --format tar \
    --prefix "${prefix}/" \
    "${version_tag}^{tree}" \
    | gzip -9 > "${archive_name}" \
    || {
        echo FAIL 1>&2
        echo 1>&2
        exit 1
    }

echo
