-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutter-version.sh
More file actions
executable file
·60 lines (47 loc) · 1.42 KB
/
flutter-version.sh
File metadata and controls
executable file
·60 lines (47 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Check if .flutter-version file exists
if [[ ! -f ".flutter-version" ]]; then
echo ".flutter-version file not found."
exit 1
fi
# Read the version tag from the file
FLUTTER_TAG=$(<.flutter-version)
# Check if the .flutter-version file is empty
if [[ -z "$FLUTTER_TAG" ]]; then
echo ".flutter-version file is empty. Please specify a Flutter version tag."
exit 1
fi
# Find the Flutter installation path
FLUTTER_PATH=$(which flutter)
if [[ -z "$FLUTTER_PATH" ]]; then
echo "Flutter is not installed or not found in your PATH."
exit 1
fi
# Get the directory of the Flutter installation
FLUTTER_DIR=$(dirname "$(dirname "$FLUTTER_PATH")")
# Change to the Flutter directory
cd "$FLUTTER_DIR" || exit
# Get the current checked-out Git tag
CURRENT_TAG=$(git describe --tags)
if [[ "$CURRENT_TAG" == "$FLUTTER_TAG" ]]; then
echo "Already on Flutter version $FLUTTER_TAG. No changes needed."
exit 0
fi
# Checkout the specified tag
git checkout "$FLUTTER_TAG"
if [[ $? -ne 0 ]]; then
echo "Failed to checkout the tag $FLUTTER_TAG."
exit 1
else
echo "Successfully checked out Flutter version $FLUTTER_TAG."
fi
# Download and install any necessary dependencies
echo "Downloading necessary dependencies..."
flutter precache
flutter doctor
if [[ $? -ne 0 ]]; then
echo "Failed to download dependencies. Please check your network connection and try again."
exit 1
else
echo "Dependencies downloaded successfully."
fi