Skip to content

Commit 8a1ff19

Browse files
committed
Add bump.sh script and VERSION file for release
1 parent 26c9358 commit 8a1ff19

2 files changed

Lines changed: 189 additions & 0 deletions

File tree

‎VERSION‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

‎scripts/bump.sh‎

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
#!/bin/bash
2+
#
3+
# Version Bump and Release Script for T-Ruby Vim/Neovim Plugin
4+
#
5+
# Usage:
6+
# ./scripts/bump.sh <type>
7+
#
8+
# Arguments:
9+
# patch Bump patch version (0.1.0 -> 0.1.1)
10+
# minor Bump minor version (0.1.0 -> 0.2.0)
11+
# major Bump major version (0.1.0 -> 1.0.0)
12+
#
13+
# Options:
14+
# --dry-run Show what would happen without making changes
15+
# --help Show this help message
16+
#
17+
# Examples:
18+
# ./scripts/bump.sh patch
19+
# ./scripts/bump.sh minor --dry-run
20+
21+
set -e
22+
23+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
25+
VERSION_FILE="$PROJECT_ROOT/VERSION"
26+
27+
# Colors for output
28+
RED='\033[0;31m'
29+
GREEN='\033[0;32m'
30+
YELLOW='\033[1;33m'
31+
BLUE='\033[0;34m'
32+
NC='\033[0m' # No Color
33+
34+
DRY_RUN=false
35+
BUMP_TYPE=""
36+
37+
print_help() {
38+
echo "Version Bump and Release Script for T-Ruby Vim/Neovim Plugin"
39+
echo ""
40+
echo "Usage: $0 <type> [options]"
41+
echo ""
42+
echo "Arguments:"
43+
echo " patch Bump patch version (0.1.0 -> 0.1.1)"
44+
echo " minor Bump minor version (0.1.0 -> 0.2.0)"
45+
echo " major Bump major version (0.1.0 -> 1.0.0)"
46+
echo ""
47+
echo "Options:"
48+
echo " --dry-run Show what would happen without making changes"
49+
echo " --help Show this help message"
50+
echo ""
51+
echo "This script will:"
52+
echo " 1. Bump the version in VERSION file"
53+
echo " 2. Commit the version change"
54+
echo " 3. Create a git tag (v0.x.x)"
55+
echo " 4. Push the commit and tag to trigger GitHub Actions release"
56+
}
57+
58+
log_info() {
59+
echo -e "${BLUE}[INFO]${NC} $1"
60+
}
61+
62+
log_success() {
63+
echo -e "${GREEN}[SUCCESS]${NC} $1"
64+
}
65+
66+
log_warn() {
67+
echo -e "${YELLOW}[WARN]${NC} $1"
68+
}
69+
70+
log_error() {
71+
echo -e "${RED}[ERROR]${NC} $1"
72+
}
73+
74+
get_version() {
75+
if [ -f "$VERSION_FILE" ]; then
76+
cat "$VERSION_FILE"
77+
else
78+
echo "0.1.0"
79+
fi
80+
}
81+
82+
bump_version() {
83+
local bump_type=$1
84+
85+
OLD_VERSION=$(get_version)
86+
87+
# Parse version components
88+
IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD_VERSION"
89+
90+
case $bump_type in
91+
patch)
92+
PATCH=$((PATCH + 1))
93+
;;
94+
minor)
95+
MINOR=$((MINOR + 1))
96+
PATCH=0
97+
;;
98+
major)
99+
MAJOR=$((MAJOR + 1))
100+
MINOR=0
101+
PATCH=0
102+
;;
103+
esac
104+
105+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
106+
echo "$NEW_VERSION"
107+
}
108+
109+
# Parse arguments
110+
while [[ $# -gt 0 ]]; do
111+
case $1 in
112+
patch|minor|major)
113+
BUMP_TYPE="$1"
114+
shift
115+
;;
116+
--dry-run)
117+
DRY_RUN=true
118+
shift
119+
;;
120+
--help|-h)
121+
print_help
122+
exit 0
123+
;;
124+
*)
125+
log_error "Unknown option: $1"
126+
print_help
127+
exit 1
128+
;;
129+
esac
130+
done
131+
132+
if [ -z "$BUMP_TYPE" ]; then
133+
log_error "Missing bump type (patch|minor|major)"
134+
print_help
135+
exit 1
136+
fi
137+
138+
cd "$PROJECT_ROOT"
139+
140+
# Check for uncommitted changes
141+
if [ -n "$(git status --porcelain)" ]; then
142+
log_error "Working directory is not clean. Please commit or stash changes first."
143+
exit 1
144+
fi
145+
146+
# Calculate versions
147+
OLD_VERSION=$(get_version)
148+
NEW_VERSION=$(bump_version "$BUMP_TYPE")
149+
150+
log_info "Version bump: $OLD_VERSION -> $NEW_VERSION"
151+
152+
if [ "$DRY_RUN" = true ]; then
153+
log_warn "Dry run mode - showing what would happen:"
154+
echo ""
155+
echo " 1. Update VERSION file to $NEW_VERSION"
156+
echo " 2. git commit -m \"Bump version to $NEW_VERSION\""
157+
echo " 3. git tag v$NEW_VERSION"
158+
echo " 4. git push && git push --tags"
159+
echo ""
160+
echo "This would trigger GitHub Actions to create:"
161+
echo " - GitHub Release"
162+
exit 0
163+
fi
164+
165+
# Update VERSION file
166+
log_info "Updating VERSION file..."
167+
echo "$NEW_VERSION" > "$VERSION_FILE"
168+
169+
# Commit
170+
log_info "Committing version change..."
171+
git add VERSION
172+
git commit -m "Bump version to $NEW_VERSION"
173+
174+
# Tag
175+
log_info "Creating tag v$NEW_VERSION..."
176+
git tag "v$NEW_VERSION"
177+
178+
# Push
179+
log_info "Pushing to remote..."
180+
git push && git push --tags
181+
182+
echo ""
183+
log_success "Released v$NEW_VERSION!"
184+
echo ""
185+
echo "GitHub Actions will now:"
186+
echo " - Create a GitHub Release"
187+
echo ""
188+
echo "Monitor progress: https://github.com/type-ruby/t-ruby-vim/actions"

0 commit comments

Comments
 (0)