4 ms·
I do this with plain ol' makefiles. Even for projects where Make isn't part of the build pipeline, like Rails or C++, I have a standardized makefile I put in t
by stackghost 2mo ago
I do this with plain ol' makefiles.
Even for projects where Make isn't part of the build pipeline, like Rails or C++, I have a standardized makefile I put in the project root, using includes for "secrets.mk", so I can do things like "make deploy" and it Just Works(tm).
Sometimes the old ways are best!
- adunk 2mo agoAnother neat and simple trick it to have the first target in the Makefile print out a helpful message that tells the reader what the project is and how to use it. One of those things that is useful both when you are working on the project and when you later return to it, years later.
- stackghost 2mo agoThat's definitely an option, though I prefer to just put a README. No reason you couldn't have the default make target just execute `cat README.md`
- evolve-maz 1mo agoI use this pattern for my makefiles. First item is for "help", and it dynamically scrapes all the other commands (assuming format <command>: ## <description>). So if I do 'make help' it'll list all the commands in the makefile without much extra work from me. .PHONY: help help: ## Show this help message @grep -E '^[a-zA-Z_-]+:.?## .$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' @echo "" @echo "Examples:" @echo " make deploy" @echo " make deploy-branch BRANCH=feature-x" @echo " make deploy AUTO_START=true" .PHONY: deploy deploy: ## Deploy from current branch (default main) (use AUTO_START=true to restart service after) @$(MAKE) _deploy BRANCH=$(git branch --show-current)