#!/bin/bash
# Script to create a git tag and update the version in main.goset -e
if[ -z "$1"];thenecho"Usage: $0 <version>"echo"Example: $0 v1.0.0"exit1fiTAG_NAME="$1"# Remove 'v' prefix if present (e.g., v1.0.0 -> 1.0.0)VERSION="${TAG_NAME#v}"# Path to main.goMAIN_GO="main.go"# Check if main.go existsif[ ! -f "$MAIN_GO"];thenecho"Error: $MAIN_GO not found"exit1fi# Check if we're in a git repoif ! git rev-parse --git-dir > /dev/null 2>&1;thenecho"Error: Not in a git repository"exit1fi# Check if tag already existsif git rev-parse "$TAG_NAME" > /dev/null 2>&1;thenecho"Error: Tag $TAG_NAME already exists"exit1fi# Update the version variable in main.gosed -i "s/^var version = \".*\"/var version = \"$VERSION\"/""$MAIN_GO"# Update the version variable in the frontend package.jsonjq ".version = \"$VERSION\"""internal/dashboard/frontend/package.json" > "internal/dashboard/frontend/package.json.tmp"mv "internal/dashboard/frontend/package.json.tmp""internal/dashboard/frontend/package.json"# Build the frontendmake build-frontend
echo"Version updated to $VERSION"