#!/bin/bash # Script to check if Gradio version in README.md matches the one in requirements.txt # Used as a pre-commit hook to ensure versions don't get out of sync # Extract version from README.md README_VERSION=$(grep -E "sdk_version:" README.md | sed -E 's/.*sdk_version:[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+).*/\1/') # Extract version from requirements.txt REQUIREMENTS_VERSION=$(grep -E "^gradio==" requirements.txt | sed -E 's/gradio==([0-9]+\.[0-9]+\.[0-9]+).*/\1/') # Check if versions were found if [ -z "$README_VERSION" ]; then echo "Error: Gradio version not found in README.md" exit 1 fi if [ -z "$REQUIREMENTS_VERSION" ]; then echo "Error: Gradio version not found in requirements.txt" exit 1 fi # Compare versions if [ "$README_VERSION" != "$REQUIREMENTS_VERSION" ]; then echo "Error: Gradio version mismatch!" echo " README.md: $README_VERSION" echo " requirements.txt: $REQUIREMENTS_VERSION" echo "Please update the versions to match before committing." exit 1 fi echo "✓ Gradio versions match ($README_VERSION)" exit 0