rebuild Go binaries in version bump script

This commit is contained in:
Steve Yegge
2025-11-21 09:45:27 -05:00
parent 1806183d5f
commit ff3ccdd26e

View File

@@ -9,7 +9,7 @@ NC='\033[0m' # No Color
# Usage message # Usage message
usage() { usage() {
echo "Usage: $0 <version> [--commit] [--tag] [--push]" echo "Usage: $0 <version> [--commit] [--tag] [--push] [--install]"
echo "" echo ""
echo "Bump version across all beads components." echo "Bump version across all beads components."
echo "" echo ""
@@ -18,12 +18,15 @@ usage() {
echo " --commit Automatically create a git commit (optional)" echo " --commit Automatically create a git commit (optional)"
echo " --tag Create annotated git tag after commit (requires --commit)" echo " --tag Create annotated git tag after commit (requires --commit)"
echo " --push Push commit and tag to origin (requires --commit and --tag)" 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 ""
echo "Examples:" echo "Examples:"
echo " $0 0.9.3 # Update versions and show diff" 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 # Update versions and commit"
echo " $0 0.9.3 --commit --tag # Update, commit, and tag" 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 --tag --push # Full release preparation"
echo " $0 0.9.3 --commit --install # Update, commit, and install"
exit 1 exit 1
} }
@@ -68,6 +71,7 @@ main() {
AUTO_COMMIT=false AUTO_COMMIT=false
AUTO_TAG=false AUTO_TAG=false
AUTO_PUSH=false AUTO_PUSH=false
AUTO_INSTALL=false
# Parse flags # Parse flags
shift # Remove version argument shift # Remove version argument
@@ -82,6 +86,9 @@ main() {
--push) --push)
AUTO_PUSH=true AUTO_PUSH=true
;; ;;
--install)
AUTO_INSTALL=true
;;
*) *)
echo -e "${RED}Error: Unknown option '$1'${NC}" echo -e "${RED}Error: Unknown option '$1'${NC}"
usage usage
@@ -228,6 +235,43 @@ main() {
echo "" 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 # Auto-commit if requested
if [ "$AUTO_COMMIT" = true ]; then if [ "$AUTO_COMMIT" = true ]; then
echo "Creating git commit..." echo "Creating git commit..."
@@ -280,16 +324,26 @@ Generated by scripts/bump-version.sh"
echo "Monitor: https://github.com/steveyegge/beads/actions" echo "Monitor: https://github.com/steveyegge/beads/actions"
elif [ "$AUTO_TAG" = true ]; then elif [ "$AUTO_TAG" = true ]; then
echo "Next steps:" 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 main"
echo " git push origin v$NEW_VERSION" echo " git push origin v$NEW_VERSION"
else else
echo "Next steps:" 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 main"
echo " git tag -a v$NEW_VERSION -m 'Release v$NEW_VERSION'" echo " git tag -a v$NEW_VERSION -m 'Release v$NEW_VERSION'"
echo " git push origin v$NEW_VERSION" echo " git push origin v$NEW_VERSION"
fi fi
else else
echo "Review the changes above. To commit:" 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 add -A"
echo " git commit -m 'chore: Bump version to $NEW_VERSION'" echo " git commit -m 'chore: Bump version to $NEW_VERSION'"
echo " git tag -a v$NEW_VERSION -m 'Release v$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 " git push origin v$NEW_VERSION"
echo "" echo ""
echo "Or run with flags to automate:" echo "Or run with flags to automate:"
echo " $0 $NEW_VERSION --commit --tag --push" echo " $0 $NEW_VERSION --commit --tag --push --install"
fi fi
} }