|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Script that updates the Clix Flutter SDK version in pubspec.yaml and README.md. |
| 4 | +# |
| 5 | +# This script updates: |
| 6 | +# 1. pubspec.yaml - The Flutter package specification file |
| 7 | +# 2. README.md - The installation instructions |
| 8 | +# |
| 9 | +# Usage: ./scripts/update-version.sh "1.0.0" |
| 10 | + |
| 11 | +set -e |
| 12 | + |
| 13 | +NEW_VERSION="$1" |
| 14 | + |
| 15 | +if [ -z "$NEW_VERSION" ]; then |
| 16 | + echo "Error: Version number is required" |
| 17 | + echo "Usage: ./scripts/update-version.sh \"1.0.0\"" |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | + |
| 21 | +RELATIVE_PATH_TO_SCRIPTS_DIR=$(dirname "$0") |
| 22 | +ABSOLUTE_PATH_TO_ROOT_DIR=$(realpath "$RELATIVE_PATH_TO_SCRIPTS_DIR/..") |
| 23 | + |
| 24 | +# File paths |
| 25 | +PUBSPEC_FILE="$ABSOLUTE_PATH_TO_ROOT_DIR/pubspec.yaml" |
| 26 | +README_FILE="$ABSOLUTE_PATH_TO_ROOT_DIR/README.md" |
| 27 | + |
| 28 | +echo "🔄 Updating Clix Flutter SDK to version: $NEW_VERSION" |
| 29 | +echo "" |
| 30 | + |
| 31 | +# 1. Update pubspec.yaml |
| 32 | +echo "📝 Updating pubspec.yaml: $PUBSPEC_FILE" |
| 33 | +if [ ! -f "$PUBSPEC_FILE" ]; then |
| 34 | + echo "Error: pubspec.yaml not found at $PUBSPEC_FILE" |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | + |
| 38 | +# Use sed to replace the version string in pubspec.yaml |
| 39 | +# Pattern matches: `version: 0.0.3` |
| 40 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 41 | + # macOS version of sed |
| 42 | + sed -i '' "s/^version: .*/version: $NEW_VERSION/" "$PUBSPEC_FILE" |
| 43 | +else |
| 44 | + # Linux version of sed |
| 45 | + sed -i "s/^version: .*/version: $NEW_VERSION/" "$PUBSPEC_FILE" |
| 46 | +fi |
| 47 | + |
| 48 | +echo "✅ Updated pubspec.yaml" |
| 49 | +echo "" |
| 50 | + |
| 51 | +# 2. Update README.md |
| 52 | +echo "📝 Updating README.md: $README_FILE" |
| 53 | +if [ ! -f "$README_FILE" ]; then |
| 54 | + echo "Error: README file not found at $README_FILE" |
| 55 | + exit 1 |
| 56 | +fi |
| 57 | + |
| 58 | +# Use sed to replace the version string in README.md |
| 59 | +# Pattern matches: `clix_flutter: ^0.0.3` |
| 60 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 61 | + # macOS version of sed |
| 62 | + sed -i '' "s/clix_flutter: \^[0-9]*\.[0-9]*\.[0-9]*/clix_flutter: ^$NEW_VERSION/" "$README_FILE" |
| 63 | +else |
| 64 | + # Linux version of sed |
| 65 | + sed -i "s/clix_flutter: \^[0-9]*\.[0-9]*\.[0-9]*/clix_flutter: ^$NEW_VERSION/" "$README_FILE" |
| 66 | +fi |
| 67 | + |
| 68 | +echo "✅ Updated README.md" |
| 69 | +echo "" |
| 70 | + |
| 71 | +# Show changes |
| 72 | +echo "🔍 Showing changes to confirm they worked:" |
| 73 | +echo "" |
| 74 | + |
| 75 | +echo "--- Changes to pubspec.yaml ---" |
| 76 | +git --no-pager diff "$PUBSPEC_FILE" || echo "No git repository or no changes detected" |
| 77 | +echo "" |
| 78 | + |
| 79 | +echo "--- Changes to README.md ---" |
| 80 | +git --no-pager diff "$README_FILE" || echo "No git repository or no changes detected" |
| 81 | +echo "" |
| 82 | + |
| 83 | +echo "🎉 Version update completed successfully!" |
| 84 | +echo "📦 New version: $NEW_VERSION" |
| 85 | +echo "" |
| 86 | +echo "Next steps:" |
| 87 | +echo "1. Review the changes above" |
| 88 | +echo "2. Update CHANGELOG.md with release notes" |
| 89 | +echo "3. Run tests: make test" |
| 90 | +echo "4. Commit changes: git add . && git commit -m \"chore: bump version to $NEW_VERSION\"" |
| 91 | +echo "5. Create tag: git tag $NEW_VERSION" |
| 92 | +echo "6. Push: git push origin main --tags" |
0 commit comments