set -e
VERSION=$1
PROJECT=pdf-canvas
if [ "$VERSION" == "" ]; then
echo "A release needs a version number!"
exit 1
fi
sed -e "s#^version.*#version = \"$VERSION\"#" < Cargo.toml > Cargo.toml.new
mv Cargo.toml.new Cargo.toml
LOG=`mktemp --suffix=.buildlog`
function error {
cat $LOG
exit 1
}
date +'%F %T: Testing ...'
cargo test > $LOG 2>&1 || error
date +'%F %T: Comitting the release ...'
git add Cargo.toml
git commit -m "Release $VERSION"
git tag -a v$VERSION
git push --all
git push --tags
date +'%F %T: Publishing the release to crates.io ...'
cargo publish
date +"%F %T: Release $VERSION done."