Skip to content

Commit 26b97c8

Browse files
author
CIS Guru
committed
refactor: decouple DB version bump from app version bump (--bump-db flag)
1 parent bc1eea9 commit 26b97c8

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

bump-version.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
#!/bin/bash
22

33
# Nine Semantic Version Bumper
4-
# Usage: ./bump-version.sh [major|minor|patch]
4+
# Usage: ./bump-version.sh [major|minor|patch] [--bump-db]
5+
#
6+
# App version and database schema version are independent.
7+
# Pass --bump-db only when this release includes a schema change.
8+
# Without --bump-db the DatabaseFileName in appsettings.json is left unchanged.
59

610
set -e
711

812
VERSION_TYPE="${1:-patch}"
13+
BUMP_DB=false
14+
for arg in "$@"; do
15+
if [ "$arg" == "--bump-db" ]; then
16+
BUMP_DB=true
17+
fi
18+
done
919
CSPROJ_FILE="4-Nine/Nine.csproj"
1020
APPSETTINGS_FILE="4-Nine/appsettings.json"
1121

@@ -37,7 +47,7 @@ case "$VERSION_TYPE" in
3747
MAJOR=$((MAJOR + 1))
3848
MINOR=0
3949
PATCH=0
40-
echo -e "Bump Type: ${YELLOW}MAJOR${NC} (breaking changes, database migration required)"
50+
echo -e "Bump Type: ${YELLOW}MAJOR${NC} (breaking changes)"
4151
;;
4252
minor)
4353
MINOR=$((MINOR + 1))
@@ -80,8 +90,8 @@ sed -i "s|<InformationalVersion>$CURRENT_VERSION</InformationalVersion>|<Informa
8090
echo -e "${YELLOW}📝 Updating $APPSETTINGS_FILE...${NC}"
8191
sed -i "s|\"Version\": \"$CURRENT_VERSION\"|\"Version\": \"$NEW_VERSION\"|g" "$APPSETTINGS_FILE"
8292

83-
# Update database settings if MAJOR or MINOR version changed
84-
if [ "$VERSION_TYPE" == "major" ] || [ "$VERSION_TYPE" == "minor" ]; then
93+
# Update database settings only when --bump-db is explicitly passed
94+
if [ "$BUMP_DB" == "true" ]; then
8595
echo -e "${YELLOW}📝 Updating database version to app_v${DB_VERSION}.db...${NC}"
8696

8797
# Get current database filename
@@ -101,7 +111,12 @@ if [ "$VERSION_TYPE" == "major" ] || [ "$VERSION_TYPE" == "minor" ]; then
101111
echo -e " - Previous DB: ${GREEN}$CURRENT_DB${NC}"
102112
echo -e " - ${RED}You may need to create a migration or copy the old database${NC}"
103113
else
104-
echo -e "${GREEN}✓ Database version unchanged (PATCH update)${NC}"
114+
if [ "$VERSION_TYPE" == "patch" ]; then
115+
echo -e "${GREEN}✓ Database version unchanged (PATCH update)${NC}"
116+
else
117+
echo -e "${GREEN}✓ Database version unchanged (no --bump-db flag)${NC}"
118+
echo -e " DatabaseFileName stays: ${GREEN}$(grep -oP '"DatabaseFileName": "\K[^"]+' "$APPSETTINGS_FILE")${NC}"
119+
fi
105120
fi
106121

107122
echo ""

0 commit comments

Comments
 (0)