.PHONY: patch deploy smoke clean check clippy test help
PLIST_CANONICAL := $(HOME)/Library/LaunchAgents/com.bobmatnyc.trusty-memory.plist
PLIST_LEGACY := $(HOME)/Library/LaunchAgents/com.trusty.trusty-memory.plist
SUPPORT_DIR := $(HOME)/Library/Application Support/trusty-memory
HTTP_ADDR_FILE := $(SUPPORT_DIR)/http_addr
FALLBACK_ADDR := 127.0.0.1:7070
patch:
cargo set-version --bump patch
@VERSION=$$(cargo metadata --no-deps --format-version 1 \
| python3 -c "import sys,json; print(json.load(sys.stdin)['packages'][0]['version'])") && \
git add Cargo.toml Cargo.lock && \
git commit -m "chore(release): bump trusty-memory to v$$VERSION" && \
git tag "trusty-memory-v$$VERSION" && \
git push origin main && \
git push origin "trusty-memory-v$$VERSION" && \
echo ">> pushed trusty-memory-v$$VERSION -- CI will publish to crates.io automatically" && \
echo ">> run 'make deploy' once CI finishes to install the new binary locally"
deploy:
-launchctl unload $(PLIST_CANONICAL) 2>/dev/null
-launchctl unload $(PLIST_LEGACY) 2>/dev/null
-rm -f $(PLIST_LEGACY)
-trusty-memory service stop 2>/dev/null
-pkill -TERM -x trusty-memory 2>/dev/null
sleep 2
CARGO_BUILD_JOBS=2 cargo install --path . --locked
launchctl load $(PLIST_CANONICAL) 2>/dev/null || trusty-memory service start
smoke:
@echo ">> trusty-memory smoke test"
@ADDR="$(FALLBACK_ADDR)"; \
if [ -f "$(HTTP_ADDR_FILE)" ]; then \
ADDR=$$(cat "$(HTTP_ADDR_FILE)"); \
echo ">> using address from http_addr: $$ADDR"; \
else \
echo ">> http_addr file not found; using fallback $$ADDR"; \
fi; \
echo ">> probing http://$$ADDR/health"; \
curl -sf "http://$$ADDR/health" | python3 -m json.tool || \
(echo "ERROR: health check failed on $$ADDR" && exit 1)
@echo ">> also probing fallback http://$(FALLBACK_ADDR)/health (no-op if same)"; \
curl -sf "http://$(FALLBACK_ADDR)/health" >/dev/null 2>&1 && \
echo ">> $(FALLBACK_ADDR) reachable" || \
echo " ($(FALLBACK_ADDR) not reachable -- OK if daemon bound elsewhere)"
@BIN_VERSION=$$(trusty-memory --version 2>&1 | awk '{print $$2}'); \
CARGO_VERSION=$$(cargo metadata --no-deps --format-version 1 \
| python3 -c "import sys,json; print(json.load(sys.stdin)['packages'][0]['version'])"); \
echo ">> binary version: $$BIN_VERSION"; \
echo ">> Cargo.toml version: $$CARGO_VERSION"; \
if [ "$$BIN_VERSION" = "$$CARGO_VERSION" ]; then \
echo ">> versions match -- smoke PASSED"; \
else \
echo "WARNING: version mismatch (run 'make deploy' to update binary)"; \
fi
clean:
cargo clean
check:
cargo check --workspace
clippy:
cargo clippy --workspace --all-targets -- -D warnings
test:
cargo test --workspace
help:
@printf '\ntrustY-memory Makefile targets\n'
@printf '%-10s %s\n' \
patch "Bump patch version, commit, tag, and push" \
deploy "Build + install binary, restart both launchd daemons" \
smoke "Health-check both ports, verify version matches" \
clean "Remove build artifacts (cargo clean)" \
check "cargo check --workspace" \
clippy "cargo clippy --workspace --all-targets" \
test "cargo test --workspace" \
help "Show this help"
@printf '\nLaunchd plists managed:\n'
@printf ' %s\n' \
"$(PLIST_CANONICAL)" \
"$(PLIST_LEGACY)"
@printf '\n'