Skip to content

Commit 8ba6f4a

Browse files
ndbroadbentclaude
andcommitted
Add scripts/bump-version.sh for version management
Usage: scripts/bump-version.sh {major|minor|patch} 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d4037c8 commit 8ba6f4a

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

scripts/bump-version.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
VERSION_FILE="$SCRIPT_DIR/../lib/log_struct/version.rb"
6+
7+
usage() {
8+
echo "Usage: $0 {major|minor|patch}"
9+
echo
10+
echo "Bumps the version in lib/log_struct/version.rb"
11+
echo
12+
echo "Examples:"
13+
echo " $0 patch # 0.1.11 -> 0.1.12"
14+
echo " $0 minor # 0.1.11 -> 0.2.0"
15+
echo " $0 major # 0.1.11 -> 1.0.0"
16+
exit 1
17+
}
18+
19+
if [[ $# -ne 1 ]]; then
20+
usage
21+
fi
22+
23+
BUMP_TYPE="$1"
24+
25+
if [[ ! "$BUMP_TYPE" =~ ^(major|minor|patch)$ ]]; then
26+
echo "Error: Invalid bump type '$BUMP_TYPE'"
27+
usage
28+
fi
29+
30+
# Extract current version
31+
CURRENT_VERSION=$(grep -oE 'VERSION = "[0-9]+\.[0-9]+\.[0-9]+"' "$VERSION_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
32+
33+
if [[ -z "$CURRENT_VERSION" ]]; then
34+
echo "Error: Could not find VERSION in $VERSION_FILE"
35+
exit 1
36+
fi
37+
38+
# Parse version components
39+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
40+
41+
# Bump the appropriate component
42+
case "$BUMP_TYPE" in
43+
major)
44+
MAJOR=$((MAJOR + 1))
45+
MINOR=0
46+
PATCH=0
47+
;;
48+
minor)
49+
MINOR=$((MINOR + 1))
50+
PATCH=0
51+
;;
52+
patch)
53+
PATCH=$((PATCH + 1))
54+
;;
55+
esac
56+
57+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
58+
59+
# Update the version file
60+
sed -i '' "s/VERSION = \"$CURRENT_VERSION\"/VERSION = \"$NEW_VERSION\"/" "$VERSION_FILE"
61+
62+
echo "Bumped version: $CURRENT_VERSION -> $NEW_VERSION"

0 commit comments

Comments
 (0)