.PHONY: all check fmt lint test build clean dry-run publish help
CARGO := cargo
CRATE_NAME := watch-and-commit
BIN_NAME := wac
VERSION := $(shell grep '^version' Cargo.toml | sed 's/version = "\(.*\)"/\1/' | tr -d ' ')
all: help
check-tools:
@command -v cargo >/dev/null 2>&1 || { echo "cargo is not installed"; exit 1; }
@command -v git >/dev/null 2>&1 || { echo "git is not installed"; exit 1; }
@echo "All required tools found"
fmt:
$(CARGO) fmt --all
lint:
$(CARGO) clippy -- -D warnings
test:
$(CARGO) test
build:
$(CARGO) build --release
check: fmt lint test build
@echo "All checks passed for v$(VERSION)"
verify:
$(CARGO) verify-project
@echo "Verified: $(CRATE_NAME) v$(VERSION)"
dry-run: check verify
$(CARGO) publish --dry-run
@echo "Dry run successful for $(CRATE_NAME) v$(VERSION)"
tag:
@if git rev-parse "v$(VERSION)" >/dev/null 2>&1; then \
echo "Tag v$(VERSION) already exists"; \
exit 1; \
fi
git tag -a "v$(VERSION)" -m "Release v$(VERSION)"
git push origin "v$(VERSION)"
@echo "Tagged and pushed v$(VERSION)"
publish: dry-run tag
$(CARGO) publish
@echo "Published $(CRATE_NAME) v$(VERSION) to crates.io"
clean:
$(CARGO) clean
help:
@echo "Usage: make [target]"
@echo ""
@echo " $(CRATE_NAME) v$(VERSION)"
@echo ""
@echo "Targets:"
@echo " fmt Format source code"
@echo " lint Run clippy lints"
@echo " test Run test suite"
@echo " build Build release binary"
@echo " check Run fmt + lint + test + build"
@echo " verify Validate Cargo.toml"
@echo " dry-run Simulate publishing without uploading"
@echo " tag Create and push git version tag"
@echo " publish Full publish pipeline to crates.io"
@echo " clean Remove build artifacts"