Skip to content

Commit 2c3f0f3

Browse files
committed
feat: add release script for version bumping
- Add scripts/release.sh for automated releases - Supports major/minor/patch bumps with alpha/beta/stable channels - Commits, tags, and pushes automatically - Add release documentation to CLAUDE.md
1 parent e54078a commit 2c3f0f3

2 files changed

Lines changed: 169 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@ pnpm build:win # Build Windows installer
2020
pnpm build:linux # Build Linux packages
2121
```
2222

23+
## Releasing
24+
25+
Use the release script to bump versions, create tags, and push:
26+
27+
```bash
28+
./scripts/release.sh <bump-type> [channel]
29+
```
30+
31+
**Bump types:**
32+
- `major` - Bump major version (1.0.0 → 2.0.0)
33+
- `minor` - Bump minor version (1.0.0 → 1.1.0)
34+
- `patch` - Bump patch version (1.0.0 → 1.0.1)
35+
36+
**Channels (optional):**
37+
- `alpha` - Add `-alpha` suffix (pre-release)
38+
- `beta` - Add `-beta` suffix (pre-release)
39+
- `stable` - No suffix (default if omitted)
40+
41+
**Examples:**
42+
```bash
43+
./scripts/release.sh minor alpha # 1.0.0 → 1.1.0-alpha
44+
./scripts/release.sh patch beta # 1.1.0-alpha → 1.1.1-beta
45+
./scripts/release.sh major # 1.1.1-beta → 2.0.0 (stable)
46+
./scripts/release.sh patch stable # 1.0.0-alpha → 1.0.1 (removes suffix)
47+
```
48+
49+
The script will:
50+
1. Validate there are no uncommitted changes
51+
2. Calculate the new version
52+
3. Prompt for confirmation
53+
4. Update `package.json`
54+
5. Commit, tag, and push
55+
2356
## Architecture
2457

2558
### Electron Process Structure

scripts/release.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Colors for output
6+
RED='\033[0;31m'
7+
GREEN='\033[0;32m'
8+
YELLOW='\033[1;33m'
9+
BLUE='\033[0;34m'
10+
NC='\033[0m' # No Color
11+
12+
# Get the script directory and project root
13+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
15+
16+
usage() {
17+
echo -e "${BLUE}Usage:${NC} $0 <bump-type> [channel]"
18+
echo ""
19+
echo -e "${BLUE}Bump types:${NC}"
20+
echo " major - Bump major version (1.0.0 -> 2.0.0)"
21+
echo " minor - Bump minor version (1.0.0 -> 1.1.0)"
22+
echo " patch - Bump patch version (1.0.0 -> 1.0.1)"
23+
echo ""
24+
echo -e "${BLUE}Channels (optional):${NC}"
25+
echo " alpha - Add -alpha suffix"
26+
echo " beta - Add -beta suffix"
27+
echo " stable - Remove any channel suffix (default if omitted)"
28+
echo ""
29+
echo -e "${BLUE}Examples:${NC}"
30+
echo " $0 minor alpha # 1.0.0 -> 1.1.0-alpha"
31+
echo " $0 patch beta # 1.1.0-alpha -> 1.1.1-beta"
32+
echo " $0 major # 1.1.1-beta -> 2.0.0"
33+
echo " $0 patch stable # 1.0.0-alpha -> 1.0.1"
34+
exit 1
35+
}
36+
37+
# Validate arguments
38+
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
39+
usage
40+
fi
41+
42+
BUMP_TYPE=$1
43+
CHANNEL=${2:-stable}
44+
45+
if [[ ! "$BUMP_TYPE" =~ ^(major|minor|patch)$ ]]; then
46+
echo -e "${RED}Error:${NC} Invalid bump type '$BUMP_TYPE'"
47+
usage
48+
fi
49+
50+
if [[ ! "$CHANNEL" =~ ^(alpha|beta|stable)$ ]]; then
51+
echo -e "${RED}Error:${NC} Invalid channel '$CHANNEL'"
52+
usage
53+
fi
54+
55+
# Change to project root
56+
cd "$PROJECT_ROOT"
57+
58+
# Check for uncommitted changes (excluding package.json since we'll modify it)
59+
if [ -n "$(git status --porcelain | grep -v 'package.json')" ]; then
60+
echo -e "${RED}Error:${NC} You have uncommitted changes. Please commit or stash them first."
61+
git status --short
62+
exit 1
63+
fi
64+
65+
# Get current version from package.json
66+
CURRENT_VERSION=$(node -p "require('./package.json').version")
67+
echo -e "${BLUE}Current version:${NC} $CURRENT_VERSION"
68+
69+
# Parse current version (strip any existing channel suffix)
70+
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/-(alpha|beta)$//')
71+
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
72+
73+
# Bump version based on type
74+
case $BUMP_TYPE in
75+
major)
76+
MAJOR=$((MAJOR + 1))
77+
MINOR=0
78+
PATCH=0
79+
;;
80+
minor)
81+
MINOR=$((MINOR + 1))
82+
PATCH=0
83+
;;
84+
patch)
85+
PATCH=$((PATCH + 1))
86+
;;
87+
esac
88+
89+
# Construct new version
90+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
91+
if [ "$CHANNEL" != "stable" ]; then
92+
NEW_VERSION="$NEW_VERSION-$CHANNEL"
93+
fi
94+
95+
echo -e "${BLUE}New version:${NC} $NEW_VERSION"
96+
97+
# Confirm with user
98+
echo ""
99+
read -p "Proceed with release v$NEW_VERSION? (y/N) " -n 1 -r
100+
echo ""
101+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
102+
echo -e "${YELLOW}Aborted.${NC}"
103+
exit 0
104+
fi
105+
106+
# Update package.json
107+
echo -e "${BLUE}Updating package.json...${NC}"
108+
node -e "
109+
const fs = require('fs');
110+
const pkg = require('./package.json');
111+
pkg.version = '$NEW_VERSION';
112+
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
113+
"
114+
115+
# Commit changes
116+
echo -e "${BLUE}Committing changes...${NC}"
117+
git add package.json
118+
git commit -m "chore: bump version to $NEW_VERSION"
119+
120+
# Create tag
121+
TAG_NAME="v$NEW_VERSION"
122+
echo -e "${BLUE}Creating tag ${TAG_NAME}...${NC}"
123+
git tag "$TAG_NAME"
124+
125+
# Push commit and tag
126+
echo -e "${BLUE}Pushing to remote...${NC}"
127+
git push
128+
git push origin "$TAG_NAME"
129+
130+
echo ""
131+
echo -e "${GREEN}✓ Released $TAG_NAME successfully!${NC}"
132+
echo ""
133+
echo -e "${BLUE}Summary:${NC}"
134+
echo " Version: $CURRENT_VERSION -> $NEW_VERSION"
135+
echo " Tag: $TAG_NAME"
136+
echo " Branch: $(git branch --show-current)"

0 commit comments

Comments
 (0)