diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 82ef4fd9..80223f45 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -9,7 +9,7 @@ NC='\033[0m' # No Color # Usage message usage() { - echo "Usage: $0 [--commit] [--tag] [--push]" + echo "Usage: $0 [--commit] [--tag] [--push] [--install]" echo "" echo "Bump version across all beads components." echo "" @@ -18,12 +18,15 @@ usage() { echo " --commit Automatically create a git commit (optional)" echo " --tag Create annotated git tag after commit (requires --commit)" echo " --push Push commit and tag to origin (requires --commit and --tag)" + echo " --install Rebuild and install bd binary to GOPATH/bin after version bump" echo "" echo "Examples:" echo " $0 0.9.3 # Update versions and show diff" + echo " $0 0.9.3 --install # Update versions and rebuild/install bd" echo " $0 0.9.3 --commit # Update versions and commit" echo " $0 0.9.3 --commit --tag # Update, commit, and tag" echo " $0 0.9.3 --commit --tag --push # Full release preparation" + echo " $0 0.9.3 --commit --install # Update, commit, and install" exit 1 } @@ -68,6 +71,7 @@ main() { AUTO_COMMIT=false AUTO_TAG=false AUTO_PUSH=false + AUTO_INSTALL=false # Parse flags shift # Remove version argument @@ -82,6 +86,9 @@ main() { --push) AUTO_PUSH=true ;; + --install) + AUTO_INSTALL=true + ;; *) echo -e "${RED}Error: Unknown option '$1'${NC}" usage @@ -228,6 +235,43 @@ main() { echo "" + # Auto-install if requested + if [ "$AUTO_INSTALL" = true ]; then + echo "Rebuilding and installing bd..." + if command -v make &> /dev/null; then + if make install; then + echo -e "${GREEN}✓ bd installed to $(go env GOPATH)/bin/bd${NC}" + echo "" + INSTALLED_VERSION=$($(go env GOPATH)/bin/bd --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) + if [ "$INSTALLED_VERSION" = "$NEW_VERSION" ]; then + echo -e "${GREEN}✓ Verified: bd --version reports $INSTALLED_VERSION${NC}" + else + echo -e "${YELLOW}⚠ Warning: bd --version reports $INSTALLED_VERSION (expected $NEW_VERSION)${NC}" + echo -e "${YELLOW} You may need to restart your shell or check your PATH${NC}" + fi + else + echo -e "${RED}✗ make install failed${NC}" + exit 1 + fi + else + if go install ./cmd/bd; then + echo -e "${GREEN}✓ bd installed to $(go env GOPATH)/bin/bd${NC}" + echo "" + INSTALLED_VERSION=$($(go env GOPATH)/bin/bd --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) + if [ "$INSTALLED_VERSION" = "$NEW_VERSION" ]; then + echo -e "${GREEN}✓ Verified: bd --version reports $INSTALLED_VERSION${NC}" + else + echo -e "${YELLOW}⚠ Warning: bd --version reports $INSTALLED_VERSION (expected $NEW_VERSION)${NC}" + echo -e "${YELLOW} You may need to restart your shell or check your PATH${NC}" + fi + else + echo -e "${RED}✗ go install failed${NC}" + exit 1 + fi + fi + echo "" + fi + # Auto-commit if requested if [ "$AUTO_COMMIT" = true ]; then echo "Creating git commit..." @@ -280,16 +324,26 @@ Generated by scripts/bump-version.sh" echo "Monitor: https://github.com/steveyegge/beads/actions" elif [ "$AUTO_TAG" = true ]; then echo "Next steps:" + if [ "$AUTO_INSTALL" = false ]; then + echo -e " ${YELLOW}make install${NC} # ⚠️ IMPORTANT: Rebuild and install bd binary!" + fi echo " git push origin main" echo " git push origin v$NEW_VERSION" else echo "Next steps:" + if [ "$AUTO_INSTALL" = false ]; then + echo -e " ${YELLOW}make install${NC} # ⚠️ IMPORTANT: Rebuild and install bd binary!" + fi echo " git push origin main" echo " git tag -a v$NEW_VERSION -m 'Release v$NEW_VERSION'" echo " git push origin v$NEW_VERSION" fi else echo "Review the changes above. To commit:" + if [ "$AUTO_INSTALL" = false ]; then + echo -e " ${YELLOW}make install${NC} # ⚠️ IMPORTANT: Rebuild and install bd binary first!" + echo "" + fi echo " git add -A" echo " git commit -m 'chore: Bump version to $NEW_VERSION'" echo " git tag -a v$NEW_VERSION -m 'Release v$NEW_VERSION'" @@ -297,7 +351,7 @@ Generated by scripts/bump-version.sh" echo " git push origin v$NEW_VERSION" echo "" echo "Or run with flags to automate:" - echo " $0 $NEW_VERSION --commit --tag --push" + echo " $0 $NEW_VERSION --commit --tag --push --install" fi }