forked from smtg-ai/claude-squad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbump-version.sh
More file actions
executable file
·47 lines (33 loc) · 1.33 KB
/
Copy pathbump-version.sh
File metadata and controls
executable file
·47 lines (33 loc) · 1.33 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
#!/bin/bash
# Bump version in main.go and create git tag (without pushing)
# Path to main.go
MAIN_FILE="main.go"
# Check if main.go exists
if [ ! -f "$MAIN_FILE" ]; then
echo "Error: $MAIN_FILE not found!"
exit 1
fi
# Read the current file content
FILE_CONTENT=$(cat "$MAIN_FILE")
# Extract current version - using a more targeted approach
CURRENT_VERSION=$(echo "$FILE_CONTENT" | grep -o 'version[ ]*=[ ]*"[0-9]\+\.[0-9]\+\.[0-9]\+"' | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
if [ -z "$CURRENT_VERSION" ]; then
echo "Error: Could not extract version from $MAIN_FILE"
exit 1
fi
echo "Current version: $CURRENT_VERSION"
# Split version into components
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
# Increment patch version
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
echo "New version: $NEW_VERSION"
# Update version in main.go - using a more direct approach with awk
awk -v old="version[ ]*=[ ]*\"$CURRENT_VERSION\"" -v new="version = \"$NEW_VERSION\"" '{gsub(old, new); print}' "$MAIN_FILE" > temp.go && mv temp.go "$MAIN_FILE"
# Commit the change
git add "$MAIN_FILE"
git commit -m "Bump version to $NEW_VERSION"
# Create git tag
git tag -a "v$NEW_VERSION" -m "Version $NEW_VERSION"
echo "✅ Version bumped to $NEW_VERSION and tag created"
echo "To push changes: git push && git push --tags"