-
-
Notifications
You must be signed in to change notification settings - Fork 546
/
Copy pathversion.sh
executable file
·56 lines (49 loc) · 1.48 KB
/
version.sh
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
#!/bin/bash
# Version validation regex pattern
VALID_VERSION_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?$'
# Prompt for version input
while true; do
read -p "Enter version number: " VERSION
# Remove 'v' prefix for validation
if [[ "${VERSION#v}" =~ $VALID_VERSION_REGEX ]]; then
# Show confirmation prompt with original input
echo "You entered version: ${VERSION}"
read -p "Is this correct? [Y/n] " confirm
case ${confirm,,} in
y|yes|"") break ;;
n|no)
echo "Restarting version input..."
continue
;;
*)
echo "Invalid input, please answer Y/n"
continue
;;
esac
else
echo "Error: Invalid version format. Please use semantic versioning (e.g. 2.0.0, v2.0.1-beta.1)"
fi
done
# Cross-platform compatible sed command
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/\"version\": \".*\"/\"version\": \"${VERSION#v}\"/" app/package.json
else
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION#v}\"/" app/package.json
fi
echo "Updated package.json to version ${VERSION#v}"
# Build app
echo "Building app..."
cd app && pnpm build
if [ $? -ne 0 ]; then
echo "Error: Build failed"
exit 1
fi
cd ..
# Run go generate
echo "Generating Go code..."
go generate ./...
if [ $? -ne 0 ]; then
echo "Error: go generate failed"
exit 1
fi
echo "Version update and generation completed successfully"