#!/bin/bash

# Fetch the latest Git tag
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))

# Remove the 'v' prefix if it exists (optional)
version=${latest_tag#v}

# Check if a tag was found
if [[ -z "$version" ]]; then
    echo "No Git tags found."
    exit 1
fi

# Update the version in Cargo.toml
# Using sed to replace the version field in Cargo.toml
sed -i.bak "s/^version = \".*\"/version = \"$version\"/" Cargo.toml

echo "Cargo version updated to $version"

