@@ -8,73 +8,75 @@ REPO_URL="https://github.com/halilertekin/CC-RouterMultiProvider"
88# Colors
99GREEN=' \033[0;32m'
1010BLUE=' \033[0;34m'
11+ YELLOW=' \033[1;33m'
1112RED=' \033[0;31m'
1213NC=' \033[0m' # No Color
1314
1415echo -e " ${BLUE} 🚀 Starting release process...${NC} "
1516
16- # 1. Get current version from package.json
17+ # 1. Choose version bump type
18+ echo -e " ${YELLOW} Select version bump type:${NC} "
19+ echo " 1) patch (1.0.0 -> 1.0.1)"
20+ echo " 2) minor (1.0.0 -> 1.1.0)"
21+ echo " 3) major (1.0.0 -> 2.0.0)"
22+ read -p " Enter choice [1-3]: " BUMP_CHOICE
23+
24+ case $BUMP_CHOICE in
25+ 1) BUMP_TYPE=" patch" ;;
26+ 2) BUMP_TYPE=" minor" ;;
27+ 3) BUMP_TYPE=" major" ;;
28+ * ) echo -e " ${RED} Invalid choice. Exiting.${NC} " ; exit 1 ;;
29+ esac
30+
31+ # 2. Check for uncommitted changes and commit if needed
32+ if [[ -n $( git status -s) ]]; then
33+ echo -e " ${YELLOW} 📝 Uncommitted changes detected. Committing...${NC} "
34+ git add .
35+ git commit -m " chore: prepare release for v$BUMP_TYPE "
36+ fi
37+
38+ # 3. Bump version using npm
39+ echo -e " ${BLUE} 🔢 Bumping $BUMP_TYPE version...${NC} "
40+ npm version $BUMP_TYPE -m " chore: release v%s" || { echo -e " ${RED} Failed to bump version.${NC} " ; exit 1; }
41+
42+ # 3. Get new version
1743VERSION=$( node -p " require('./package.json').version" )
18- echo -e " ${GREEN} 📦 Current version: v$VERSION ${NC} "
44+ echo -e " ${GREEN} 📦 New version: v$VERSION ${NC} "
1945
20- # 2. Push to GitHub
21- echo -e " ${BLUE} ⬆️ Pushing to GitHub...${NC} "
22- git push origin main
23- git push origin v$VERSION || {
24- echo -e " ${BLUE} ℹ️ Tag v$VERSION does not exist on remote. Creating and pushing...${NC} "
25- git tag v$VERSION
26- git push origin v$VERSION
27- }
46+ # 4. Push to GitHub (this will trigger CI/CD)
47+ echo -e " ${BLUE} ⬆️ Pushing to GitHub (Main and Tags)...${NC} "
48+ git push origin main && git push origin v$VERSION || { echo -e " ${RED} Failed to push to GitHub.${NC} " ; exit 1; }
2849
29- # 3 . Calculate SHA256
50+ # 5 . Calculate SHA256 for Homebrew
3051TARBALL_URL=" $REPO_URL /archive/refs/tags/v$VERSION .tar.gz"
31- echo -e " ${BLUE} 📥 Downloading tarball to calculate SHA256...${NC} "
32- echo " URL: $TARBALL_URL "
33-
34- # Download with curl and calculate sha256 (macOS compatible)
52+ echo -e " ${BLUE} 📥 Downloading tarball to calculate SHA256 for Homebrew...${NC} "
3553SHA256=$( curl -sL " $TARBALL_URL " | shasum -a 256 | awk ' {print $1}' )
3654
3755if [ -z " $SHA256 " ]; then
38- echo -e " ${RED} ❌ Failed to calculate SHA256${NC} "
39- exit 1
40- fi
41-
42- echo -e " ${GREEN} ✅ SHA256: $SHA256 ${NC} "
43-
44- # 4. Update Homebrew Formula
45- echo -e " ${BLUE} 🍺 Updating Homebrew formula...${NC} "
46-
47- # Update URL
48- sed -i ' ' " s|url " .* " |url \" $TARBALL_URL \" |" " $FORMULA_FILE "
49-
50- # Update SHA256
51- sed -i ' ' " s|sha256 " .* " |sha256 \" $SHA256 \" |" " $FORMULA_FILE "
52-
53- # Show diff
54- echo -e " ${BLUE} 📝 Formula changes:${NC} "
55- cd " $TAP_DIR "
56- git diff Formula/claude-code-router-config.rb
57-
58- # 5. Commit and Push Homebrew Tap
59- read -p " Commit and push Homebrew tap changes? (y/n) " -n 1 -r
60- echo
61- if [[ $REPLY =~ ^[Yy]$ ]]; then
62- cd " $TAP_DIR "
63- git add Formula/claude-code-router-config.rb
64- git commit -m " update: claude-code-router-config v$VERSION "
65- git push origin main
66- echo -e " ${GREEN} ✅ Homebrew tap updated!${NC} "
56+ echo -e " ${YELLOW} ⚠️ Could not calculate SHA256 automatically (maybe tag is not yet available on GitHub).${NC} "
57+ echo -e " ${YELLOW} You might need to update the Homebrew formula manually later.${NC} "
6758else
68- echo -e " ${BLUE} ℹ️ Skipping Homebrew update${NC} "
69- fi
70-
71- # 6. Publish to NPM
72- read -p " Publish to NPM? (y/n) " -n 1 -r
73- echo
74- if [[ $REPLY =~ ^[Yy]$ ]]; then
75- cd - > /dev/null
76- npm publish --access public
77- echo -e " ${GREEN} ✅ Published to NPM!${NC} "
59+ echo -e " ${GREEN} ✅ SHA256: $SHA256 ${NC} "
60+
61+ # 6. Update Homebrew Formula (if tap directory exists)
62+ if [ -d " $TAP_DIR " ] && [ -f " $FORMULA_FILE " ]; then
63+ echo -e " ${BLUE} 🍺 Updating Homebrew formula in $TAP_DIR ...${NC} "
64+
65+ # Update URL and SHA256
66+ sed -i ' ' " s|url \" .*\" |url \" $TARBALL_URL \" |" " $FORMULA_FILE "
67+ sed -i ' ' " s|sha256 \" .*\" |sha256 \" $SHA256 \" |" " $FORMULA_FILE "
68+
69+ # Commit and Push Tap
70+ cd " $TAP_DIR "
71+ git add Formula/claude-code-router-config.rb
72+ git commit -m " update: claude-code-router-config v$VERSION "
73+ git push origin main
74+ cd - > /dev/null
75+ echo -e " ${GREEN} ✅ Homebrew tap updated!${NC} "
76+ else
77+ echo -e " ${YELLOW} ℹ️ Homebrew tap directory or formula not found at $TAP_DIR . Skipping formula update.${NC} "
78+ fi
7879fi
7980
8081echo -e " ${GREEN} 🎉 Release v$VERSION complete!${NC} "
82+ echo -e " ${BLUE} GitHub Actions will now handle the NPM publication.${NC} "
0 commit comments