#!/bin/bash -eu
set -o pipefail
readonly VERSION="${1:?}"
cd "$(jj root)"
if jj show --stat | tail -n -1 | grep -q '^0 files changed'
then
jj describe -m "chore: version ${VERSION}"
else
jj new -m "chore: version ${VERSION}"
fi
cargo set-version "${VERSION//.b/-beta.}"
cargo upgrade
cargo update
cargo check
cargo test
jj new
git tag -f -m "Version ${VERSION}" "${VERSION}"
git cliff 3.0.0.b3..HEAD | head -n -3 > CHANGELOG.md
git tag -d "${VERSION}"
jj squash -u
git tag -f -m "Version ${VERSION}" "${VERSION}"