#!/bin/sh

set -eu

read src ver <<-EOF
	$(sed '1s/^\(.*\) (\(.*\)) .*$/\1 \2/; q;' changelog)
	EOF

sed '/^ -- .*  /{ s/^\( -- .*  \).*$/\1'"$(LC_ALL='POSIX' date \
	'+%a, %d %b %Y %H:%M:%S %z')"'/; :l; n; b l; };' changelog >changelog~
mv changelog~ changelog
git commit -m "changelog: Release ${src} ${ver}" -- changelog
git tag "${src}/${ver}" HEAD