diff --git a/scripts/release-integration.sh b/scripts/release-integration.sh index f6d0aa43..abe362d1 100755 --- a/scripts/release-integration.sh +++ b/scripts/release-integration.sh @@ -19,11 +19,12 @@ usage() { print_error "Usage: $0 " echo "" echo " integration One of: ${VALID_INTEGRATIONS[*]}" - echo " version Semantic version (e.g. 0.2.0)" + echo " version Semantic version (e.g. 0.2.0) or bump keyword: patch, minor, major" echo "" echo "Examples:" echo " $0 litellm 0.2.0" - echo " $0 pydantic-ai 1.0.0" + echo " $0 pydantic-ai patch" + echo " $0 crewai minor" exit 1 } @@ -32,7 +33,7 @@ if [ -z "$1" ] || [ -z "$2" ]; then fi INTEGRATION=$1 -VERSION=$2 +VERSION_ARG=$2 # Validate integration name VALID=false @@ -48,9 +49,47 @@ if [ "$VALID" = "false" ]; then exit 1 fi -# Validate version format -if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - print_error "Invalid version format. Please use semantic versioning (e.g., 0.2.0)" +# Read current version from package manifest +get_current_version() { + local dir="hindsight-integrations/$INTEGRATION" + if [ -f "$dir/pyproject.toml" ]; then + grep '^version = ' "$dir/pyproject.toml" | sed 's/version = "\(.*\)"/\1/' + elif [ -f "$dir/package.json" ]; then + grep '"version"' "$dir/package.json" | head -1 | sed 's/.*"version": "\(.*\)".*/\1/' + elif [ -f "$dir/.claude-plugin/plugin.json" ]; then + grep '"version"' "$dir/.claude-plugin/plugin.json" | head -1 | sed 's/.*"version": "\(.*\)".*/\1/' + elif [ -f "$dir/settings.json" ] && grep -q '"version"' "$dir/settings.json"; then + grep '"version"' "$dir/settings.json" | head -1 | sed 's/.*"version": "\(.*\)".*/\1/' + else + echo "" + fi +} + +# Bump a semver component: bump_version +bump_version() { + local current=$1 part=$2 + local major minor patch + IFS='.' read -r major minor patch <<< "$current" + case "$part" in + major) echo "$((major + 1)).0.0" ;; + minor) echo "$major.$((minor + 1)).0" ;; + patch) echo "$major.$minor.$((patch + 1))" ;; + esac +} + +# Resolve version: either an explicit semver or a bump keyword +if [[ "$VERSION_ARG" =~ ^(patch|minor|major)$ ]]; then + CURRENT_VERSION=$(get_current_version) + if [ -z "$CURRENT_VERSION" ]; then + print_error "Could not read current version for '$INTEGRATION'" + exit 1 + fi + VERSION=$(bump_version "$CURRENT_VERSION" "$VERSION_ARG") + print_info "Bumping $CURRENT_VERSION → $VERSION ($VERSION_ARG)" +elif [[ "$VERSION_ARG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + VERSION=$VERSION_ARG +else + print_error "Invalid version: '$VERSION_ARG'. Use a semver (e.g. 0.2.0) or bump keyword (patch, minor, major)" exit 1 fi