|
| 1 | +#!/bin/bash |
| 2 | +# Version consistency checker for Combine releases |
| 3 | +# This script verifies that version strings are consistent across the codebase |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +# Color codes for output |
| 8 | +RED='\033[0;31m' |
| 9 | +GREEN='\033[0;32m' |
| 10 | +YELLOW='\033[1;33m' |
| 11 | +NC='\033[0m' # No Color |
| 12 | + |
| 13 | +# Check if version argument is provided |
| 14 | +if [ $# -eq 0 ]; then |
| 15 | + echo -e "${RED}Error: No version specified${NC}" |
| 16 | + echo "Usage: $0 vX.Y.Z" |
| 17 | + echo "Example: $0 v10.3.2" |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | + |
| 21 | +VERSION=$1 |
| 22 | + |
| 23 | +# Validate version format |
| 24 | +if ! [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 25 | + echo -e "${RED}Error: Invalid version format${NC}" |
| 26 | + echo "Version must be in format vX.Y.Z (e.g., v10.3.2)" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +echo "Checking version consistency for ${VERSION}..." |
| 31 | +echo "" |
| 32 | + |
| 33 | +ERRORS=0 |
| 34 | + |
| 35 | +# Get script directory and repo root |
| 36 | +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 37 | +REPO_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )" |
| 38 | + |
| 39 | +# Check 1: bin/combine.cpp |
| 40 | +echo -n "Checking bin/combine.cpp... " |
| 41 | +COMBINE_CPP="$REPO_ROOT/bin/combine.cpp" |
| 42 | +if [ ! -f "$COMBINE_CPP" ]; then |
| 43 | + echo -e "${RED}FAIL${NC}" |
| 44 | + echo " File not found: $COMBINE_CPP" |
| 45 | + ERRORS=$((ERRORS + 1)) |
| 46 | +else |
| 47 | + if grep -q "std::string combineTagString = \"${VERSION}\"" "$COMBINE_CPP"; then |
| 48 | + echo -e "${GREEN}OK${NC}" |
| 49 | + else |
| 50 | + echo -e "${RED}FAIL${NC}" |
| 51 | + CURRENT=$(grep "std::string combineTagString" "$COMBINE_CPP" | sed -E 's/.*"(.*)".*/\1/') |
| 52 | + echo " Expected: std::string combineTagString = \"${VERSION}\"" |
| 53 | + echo " Found: std::string combineTagString = \"${CURRENT}\"" |
| 54 | + ERRORS=$((ERRORS + 1)) |
| 55 | + fi |
| 56 | +fi |
| 57 | + |
| 58 | +# Check 2: docs/index.md - recommended tag line |
| 59 | +echo -n "Checking docs/index.md (recommended tag)... " |
| 60 | +DOCS_INDEX="$REPO_ROOT/docs/index.md" |
| 61 | +if [ ! -f "$DOCS_INDEX" ]; then |
| 62 | + echo -e "${RED}FAIL${NC}" |
| 63 | + echo " File not found: $DOCS_INDEX" |
| 64 | + ERRORS=$((ERRORS + 1)) |
| 65 | +else |
| 66 | + # Check for the main v10 recommended tag |
| 67 | + if grep -q "Currently, the recommended tag is \*\*${VERSION}\*\*" "$DOCS_INDEX"; then |
| 68 | + echo -e "${GREEN}OK${NC}" |
| 69 | + else |
| 70 | + echo -e "${RED}FAIL${NC}" |
| 71 | + CURRENT=$(grep "Currently, the recommended tag is" "$DOCS_INDEX" | head -1 | sed -E 's/.*\*\*([v0-9.]+)\*\*.*/\1/') |
| 72 | + echo " Expected: Currently, the recommended tag is **${VERSION}**" |
| 73 | + echo " Found: Currently, the recommended tag is **${CURRENT}**" |
| 74 | + ERRORS=$((ERRORS + 1)) |
| 75 | + fi |
| 76 | +fi |
| 77 | + |
| 78 | +# Check 3: docs/index.md - git clone branch |
| 79 | +echo -n "Checking docs/index.md (git clone branch)... " |
| 80 | +if grep -q "\-\-branch ${VERSION}" "$DOCS_INDEX"; then |
| 81 | + echo -e "${GREEN}OK${NC}" |
| 82 | +else |
| 83 | + echo -e "${RED}FAIL${NC}" |
| 84 | + CURRENT=$(grep "\-\-branch v" "$DOCS_INDEX" | head -1 | sed -E 's/.*--branch ([v0-9.]+).*/\1/') |
| 85 | + echo " Expected: --branch ${VERSION}" |
| 86 | + echo " Found: --branch ${CURRENT}" |
| 87 | + ERRORS=$((ERRORS + 1)) |
| 88 | +fi |
| 89 | + |
| 90 | +# Check 4: docs/index.md - release notes link |
| 91 | +echo -n "Checking docs/index.md (release notes link)... " |
| 92 | +if grep -q "releases/tag/${VERSION}" "$DOCS_INDEX"; then |
| 93 | + echo -e "${GREEN}OK${NC}" |
| 94 | +else |
| 95 | + echo -e "${YELLOW}WARNING${NC}" |
| 96 | + echo " Release notes link not found: releases/tag/${VERSION}" |
| 97 | + echo " This is expected if the release hasn't been created yet" |
| 98 | +fi |
| 99 | + |
| 100 | +echo "" |
| 101 | +if [ $ERRORS -eq 0 ]; then |
| 102 | + echo -e "${GREEN}✓ All version checks passed!${NC}" |
| 103 | + echo "" |
| 104 | + echo "Next steps:" |
| 105 | + echo " 1. Commit the version updates:" |
| 106 | + echo " git add bin/combine.cpp docs/index.md" |
| 107 | + echo " git commit -m \"Update version to ${VERSION}\"" |
| 108 | + echo " 2. Create and push the tag:" |
| 109 | + echo " git tag -a ${VERSION} -m \"Release ${VERSION}\"" |
| 110 | + echo " git push origin main" |
| 111 | + echo " git push origin ${VERSION}" |
| 112 | + exit 0 |
| 113 | +else |
| 114 | + echo -e "${RED}✗ Found ${ERRORS} error(s)${NC}" |
| 115 | + echo "" |
| 116 | + echo "Please fix the version inconsistencies and run this script again." |
| 117 | + exit 1 |
| 118 | +fi |
0 commit comments