#!/bin/bash -eu
set -o pipefail
readonly VERSION="${1:?}"
cd "$(git rev-parse --show-toplevel)"
cargo set-version "${VERSION//.b/-beta.}"
cargo upgrade
cargo update
cargo check
cargo test
git add Cargo.{toml,lock}
git commit -m "chore: version ${VERSION}"
git tag -f -m "Version ${VERSION}" "${VERSION}"
git cliff 2.0.0.b0..HEAD | head -n -3 > CHANGELOG.md
git add CHANGELOG.md
git commit --amend --no-edit
git tag -d "${VERSION}"
git tag -f -m "Version ${VERSION}" "${VERSION}"