#!/bin/bash

set -e

print_help() {
  cat >&2 <<EOF
USAGE: bin/release [level]

Level should be one of release, patch, minor, major, alpha, beta, or rc.
See the cargo-release documentation on what each of these mean:

https://github.com/sunng87/cargo-release/blob/master/docs/reference.md

EOF
}

if [ -z "$1" ]; then
  print_help
  exit 1
fi

level=$1

if [ ! -e "$HOME/.cargo/bin/cargo-release" ]; then
    echo "Installing cargo-release..."
    cargo install cargo-release
fi

cargo release $level --skip-publish

echo "We are now at version $(cargo read-manifest | jq -r ".version")"
echo "Next step: write release notes on GitHub while the asset builds run."
open "https://github.com/entropic-dev/boltzmann/releases/"
