#!/bin/bash
set -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
project_dir=${dir}/..
cd $project_dir

v="$(cargo pkgid -p dbui | cut -d# -f2 | cut -d: -f2)"

echo "Publishing $v"

read -p "Press enter to continue"

./bin/check

git add .
git commit -m "v$v" || :

cargo publish --manifest-path dbui-core/Cargo.toml
cargo publish --manifest-path dbui-assets/Cargo.toml
echo "Waiting for assets to settle..."
sleep 15s
cargo publish --manifest-path dbui-templates/Cargo.toml
cargo publish --manifest-path dbui-database/Cargo.toml
cargo publish --manifest-path dbui-controllers/Cargo.toml
echo "Waiting for controllers to settle..."
sleep 15s
cargo publish

git tag -a "v$v" -m ""
git push
git push origin "v$v"
