#!/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 "=== core ==="
cargo publish --manifest-path core/Cargo.toml
echo "Waiting for core to settle..."
sleep 15s
echo "=== assets ==="
cargo publish --manifest-path assets/Cargo.toml
echo "=== database ==="
cargo publish --manifest-path database/Cargo.toml
echo "Waiting for database to settle..."
sleep 15s
echo "=== service ==="
cargo publish --manifest-path service/Cargo.toml
echo "=== client ==="
cargo publish --manifest-path client/Cargo.toml
echo "=== templates ==="
cargo publish --manifest-path templates/Cargo.toml
echo "Waiting for templates to settle..."
sleep 15s
echo "=== controllers ==="
cargo publish --manifest-path 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"
