-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincrement_version.sh
More file actions
executable file
·45 lines (34 loc) · 1.05 KB
/
increment_version.sh
File metadata and controls
executable file
·45 lines (34 loc) · 1.05 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
#!/bin/bash
# SoF Buddy Version Increment Script
# Automatically increments the minor version in VERSION file
VERSION_FILE="VERSION"
# Check if VERSION file exists
if [ ! -f "$VERSION_FILE" ]; then
echo "Error: VERSION file not found!"
exit 1
fi
# Read current version
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '\r\n')
echo "Current version: $CURRENT_VERSION"
# Parse major and minor versions
IFS='.' read -r MAJOR MINOR <<< "$CURRENT_VERSION"
# Validate version format
if ! [[ "$MAJOR" =~ ^[0-9]+$ ]] || ! [[ "$MINOR" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid version format. Expected MAJOR.MINOR (e.g., 1.0)"
exit 1
fi
# Increment minor version
NEW_MINOR=$((MINOR + 1))
# Handle major version reset (e.g., 1.9 → 2.0)
if [ "$NEW_MINOR" -gt 9 ]; then
NEW_MAJOR=$((MAJOR + 1))
NEW_MINOR=0
else
NEW_MAJOR=$MAJOR
fi
# Create new version string
NEW_VERSION="$NEW_MAJOR.$NEW_MINOR"
# Write new version to file
echo "$NEW_VERSION" > "$VERSION_FILE"
echo "Version incremented: $CURRENT_VERSION → $NEW_VERSION"
echo "Updated $VERSION_FILE"