Skip to content

Commit 1c01907

Browse files
refactor(release.sh): automate version increase by looking for features in changelog content
1 parent 84082ca commit 1c01907

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

ops/release.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ echo "----------------------------------------"
2525
echo "$CHANGELOG_BODY"
2626
echo "----------------------------------------"
2727

28-
# --- Step 2: Prompt for new version ---
29-
read -p "🔖 Enter new version (previous: $CURRENT_VERSION): " NEW_VERSION
30-
31-
if [[ -z "$NEW_VERSION" ]]; then
32-
echo "❌ Version is required. Aborting."
33-
exit 1
28+
# --- Step 2: Generate new version automatically ---
29+
if echo "$CHANGELOG_BODY" | grep -q "### 🚀 Features"; then
30+
echo "🚀 Features detected: bumping minor version"
31+
# Bump minor version
32+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
33+
NEW_VERSION="$MAJOR.$((MINOR + 1)).0"
34+
else
35+
echo "🐛 Patch changes: bumping patch version"
36+
# Bump patch version
37+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
38+
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
3439
fi
3540

36-
# Validate semver-ish format (basic check)
37-
if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
38-
echo "❌ Invalid version format. Must be like 1.2.3 or 1.2.3-beta.1"
39-
exit 1
40-
fi
41+
echo "🔖 New version: $NEW_VERSION (previous: $CURRENT_VERSION)"
4142

4243
# --- Step 3: Generate changelog file ---
4344
DATE=$(date +%Y-%m-%d)

0 commit comments

Comments
 (0)