set -e
VERSION=$1
PROJECT="nickel-jwt-session"
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
}
echo Testing ...
cargo test > $LOG 2>&1 || error
echo Making docs ...
cargo doc --no-deps > $LOG 2>&1 || error
echo Comitting the relase ...
git add Cargo.toml
git commit -m "Release $VERSION"
git tag -a v$VERSION
git push --all
git push --tags
echo "Publishing the release to crates.io ..."
cargo publish