#!/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/build-css
./bin/check

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

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

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