CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$CURRENT_BRANCH" != "main" ]]; then
  echo "Error: You must be on the main branch (currently on '$CURRENT_BRANCH')"
  exit 1
fi

git pull --ff-only
VERSION=$(grep '^version' Cargo.toml | head -n1 | sed -E 's/version *= *"([^"]+)"/\1/')
git add Cargo.toml Cargo.lock
git commit -m "$VERSION"
git tag $VERSION
git push origin main --tags
