#!/bin/bash

# Read current version
VERSION=$(cat VERSION)

# Split version into components
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Decide which part to bump based on the commit type
case $1 in
  major)
    ((MAJOR++))
    MINOR=0
    PATCH=0
    ;;
  minor)
    ((MINOR++))
    PATCH=0
    ;;
  patch)
    ((PATCH++))
    ;;
  *)
    echo "Usage: $0 {major|minor|patch}"
    exit 1
    ;;
esac

# Construct the new version
NEW_VERSION="$MAJOR.$MINOR.$PATCH"

# Save the new version to the VERSION file
echo "$NEW_VERSION" > VERSION
echo "Version bumped to $NEW_VERSION"

git add VERSION
git tag "v$MAJOR.$MINOR.$PATCH"
git push origin "v$MAJOR.$MINOR.$PATCH"
git push origin --tags