Skip to content

Commit 4dea693

Browse files
committed
feat: add installation script and Makefile for Bayesian SSH
- Introduced `install.sh` for automated installation of the Bayesian SSH binary. - Added `Makefile` to streamline development tasks including build, test, and installation commands. - Updated `README.md` to reflect new installation options and Makefile commands.
1 parent 25a36bd commit 4dea693

3 files changed

Lines changed: 526 additions & 18 deletions

File tree

Makefile

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Bayesian SSH Makefile
2+
# Provides common development and build tasks
3+
4+
.PHONY: help build test release clean install uninstall format lint check deps update-deps
5+
6+
# Configuration
7+
BINARY_NAME = bayesian-ssh
8+
CARGO = cargo
9+
RUSTUP = rustup
10+
TARGET_DIR = target
11+
RELEASE_DIR = $(TARGET_DIR)/release
12+
INSTALL_DIR = /usr/local/bin
13+
14+
# Default target
15+
help: ## Show this help message
16+
@echo "🚀 Bayesian SSH - Available Commands"
17+
@echo "====================================="
18+
@echo ""
19+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
20+
@echo ""
21+
@echo "📚 Examples:"
22+
@echo " make build # Build debug version"
23+
@echo " make release # Build release version"
24+
@echo " make test # Run all tests"
25+
@echo " make install # Install to system"
26+
@echo " make clean # Clean build artifacts"
27+
28+
# Build targets
29+
build: ## Build debug version
30+
@echo "🔨 Building debug version..."
31+
$(CARGO) build
32+
@echo "✅ Build completed"
33+
34+
release: ## Build release version
35+
@echo "🔨 Building release version..."
36+
$(CARGO) build --release
37+
@echo "✅ Release build completed"
38+
@echo "📊 Binary size: $(shell ls -lh $(RELEASE_DIR)/$(BINARY_NAME) 2>/dev/null | awk '{print $$5}' || echo "N/A")"
39+
40+
# Testing and quality
41+
test: ## Run all tests
42+
@echo "🧪 Running tests..."
43+
$(CARGO) test
44+
@echo "✅ Tests completed"
45+
46+
check: ## Run cargo check
47+
@echo "🔍 Running cargo check..."
48+
$(CARGO) check
49+
@echo "✅ Check completed"
50+
51+
format: ## Format code with rustfmt
52+
@echo "🎨 Formatting code..."
53+
$(CARGO) fmt --all
54+
@echo "✅ Formatting completed"
55+
56+
format-check: ## Check code formatting
57+
@echo "🎨 Checking code formatting..."
58+
$(CARGO) fmt --all -- --check
59+
@echo "✅ Formatting check completed"
60+
61+
lint: ## Run clippy linter
62+
@echo "🔍 Running clippy..."
63+
$(CARGO) clippy -- -D warnings
64+
@echo "✅ Linting completed"
65+
66+
# Dependencies
67+
deps: ## Install development dependencies
68+
@echo "📦 Installing development dependencies..."
69+
$(RUSTUP) component add rustfmt
70+
$(RUSTUP) component add clippy
71+
@echo "✅ Dependencies installed"
72+
73+
update-deps: ## Update Rust toolchain and dependencies
74+
@echo "🔄 Updating Rust toolchain..."
75+
$(RUSTUP) update
76+
@echo "🔄 Updating Cargo dependencies..."
77+
$(CARGO) update
78+
@echo "✅ Updates completed"
79+
80+
# Installation
81+
install: release ## Install binary to system
82+
@echo "📦 Installing $(BINARY_NAME)..."
83+
@if [ -f "$(RELEASE_DIR)/$(BINARY_NAME)" ]; then \
84+
sudo cp "$(RELEASE_DIR)/$(BINARY_NAME)" "$(INSTALL_DIR)/$(BINARY_NAME)"; \
85+
echo "$(BINARY_NAME) installed to $(INSTALL_DIR)"; \
86+
else \
87+
echo "❌ Release binary not found. Run 'make release' first."; \
88+
exit 1; \
89+
fi
90+
91+
uninstall: ## Remove binary from system
92+
@echo "🗑️ Uninstalling $(BINARY_NAME)..."
93+
@if [ -f "$(INSTALL_DIR)/$(BINARY_NAME)" ]; then \
94+
sudo rm "$(INSTALL_DIR)/$(BINARY_NAME)"; \
95+
echo "$(BINARY_NAME) uninstalled from $(INSTALL_DIR)"; \
96+
else \
97+
echo "ℹ️ $(BINARY_NAME) not found in $(INSTALL_DIR)"; \
98+
fi
99+
100+
# Development workflow
101+
dev: format lint test ## Run full development workflow
102+
@echo "🎉 Development workflow completed!"
103+
104+
pre-commit: format lint test ## Run before committing
105+
@echo "🎉 Pre-commit checks passed!"
106+
107+
# Cleanup
108+
clean: ## Clean build artifacts
109+
@echo "🧹 Cleaning build artifacts..."
110+
$(CARGO) clean
111+
@echo "✅ Cleanup completed"
112+
113+
distclean: clean ## Deep clean (removes target and Cargo.lock)
114+
@echo "🧹 Deep cleaning..."
115+
rm -rf $(TARGET_DIR)
116+
rm -f Cargo.lock
117+
@echo "✅ Deep cleanup completed"
118+
119+
# Release management
120+
version: ## Show current version
121+
@echo "📋 Current version: $(shell grep '^version = ' Cargo.toml | cut -d'"' -f2)"
122+
123+
bump-patch: ## Bump patch version
124+
@echo "🔄 Bumping patch version..."
125+
@./scripts/build_and_push.sh --version $(shell ./scripts/build_and_push.sh --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | awk -F. '{print $$1"."$$2"."$$3+1}')
126+
@echo "✅ Version bumped"
127+
128+
bump-minor: ## Bump minor version
129+
@echo "🔄 Bumping minor version..."
130+
@./scripts/build_and_push.sh --version $(shell ./scripts/build_and_push.sh --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | awk -F. '{print $$1"."$$2+1".0"}')
131+
@echo "✅ Version bumped"
132+
133+
bump-major: ## Bump major version
134+
@echo "🔄 Bumping major version..."
135+
@./scripts/build_and_push.sh --version $(shell ./scripts/build_and_push.sh --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | awk -F. '{print $$1+1".0.0"}')
136+
@echo "✅ Version bumped"
137+
138+
# Quick shortcuts
139+
all: clean deps build test release ## Full build pipeline
140+
@echo "🎉 Full build pipeline completed!"
141+
142+
quick: build test ## Quick build and test
143+
@echo "🎉 Quick build and test completed!"
144+
145+
# Documentation
146+
docs: ## Build documentation
147+
@echo "📚 Building documentation..."
148+
$(CARGO) doc --no-deps --open
149+
@echo "✅ Documentation built"
150+
151+
# Show binary info
152+
info: release ## Show binary information
153+
@echo "📊 Binary Information:"
154+
@echo " Location: $(RELEASE_DIR)/$(BINARY_NAME)"
155+
@echo " Size: $(shell ls -lh $(RELEASE_DIR)/$(BINARY_NAME) 2>/dev/null | awk '{print $$5}' || echo "N/A")"
156+
@echo " Version: $(shell grep '^version = ' Cargo.toml | cut -d'"' -f2)"
157+
@echo " Build time: $(shell date)"

README.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,24 @@
2020
## 🚀 Quick Start
2121

2222
### Installation
23+
24+
#### Option 1: One-liner Install (Recommended)
25+
```bash
26+
# Install latest release automatically
27+
curl -fsSL https://raw.githubusercontent.com/abdoufermat5/bayesian-ssh/main/install.sh | bash
28+
```
29+
30+
#### Option 2: Manual Build
2331
```bash
2432
# Clone and build
2533
git clone https://github.com/abdoufermat5/bayesian-ssh.git
2634
cd bayesian-ssh
2735

28-
# Build and install
36+
# Build and install using Makefile
37+
make release
38+
make install
39+
40+
# Or use the script
2941
./scripts/build_and_push.sh --release
3042
sudo cp target/release/bayesian-ssh /usr/local/bin/
3143
```
@@ -73,25 +85,30 @@ bayesian-ssh add "Server" host.com --bastion custom-bastion.com
7385

7486
## 🔧 Development & Release
7587

76-
### Build Scripts
88+
### Makefile Commands
7789
```bash
78-
# Build and test
79-
./scripts/build_and_push.sh
90+
# Show all available commands
91+
make help
8092

81-
# Build release version
82-
./scripts/build_and_push.sh --release
83-
84-
# Update version and build
85-
./scripts/build_and_push.sh --version X.Y.Z
86-
87-
# Create release (build, tag, and push tag)
88-
./scripts/build_and_push.sh --release --create-release
89-
90-
# Full release workflow with version update
91-
./scripts/build_and_push.sh --version X.Y.Z --release --create-release
92-
93-
# Clean all tags and releases
94-
./scripts/clean_releases.sh
93+
# Build and test
94+
make build # Debug build
95+
make release # Release build
96+
make test # Run tests
97+
make install # Install to system
98+
99+
# Code quality
100+
make format # Format code
101+
make lint # Run clippy
102+
make check # Cargo check
103+
104+
# Development workflow
105+
make dev # Full dev workflow
106+
make pre-commit # Pre-commit checks
107+
108+
# Version management
109+
make bump-patch # Bump patch version
110+
make bump-minor # Bump minor version
111+
make bump-major # Bump major version
95112
```
96113

97114
### Configuration

0 commit comments

Comments
 (0)