#!/usr/bin/env sh

set -eux

# If there is a change in version number, add a git tag
PROJECT_VERSION_OLD="$(jj tag list --sort name- | head -n 1 | cut -d ":" -f 1)"
PROJECT_VERSION_NEW="$(jj file show pyproject.toml --revision=@ | grep "version" | cut -d '"' -f 2 | cut -d "'" -f 2)"

if [ "${PROJECT_VERSION_NEW}" != "${PROJECT_VERSION_OLD}" ]; then
  jj tag set ${PROJECT_VERSION_NEW}
fi
