Last active
November 27, 2018 13:30
-
-
Save tadashi-aikawa/da73d277a3c1ec6767ed48d1335900f3 to your computer and use it in GitHub Desktop.
Makefileのテンプレ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAKEFLAGS += --warn-undefined-variables | |
SHELL := /bin/bash | |
ARGS := | |
.SHELLFLAGS := -eu -o pipefail -c | |
.DEFAULT_GOAL := help | |
.PHONY: $(shell egrep -oh ^[a-zA-Z0-9][a-zA-Z0-9_-]+: $(MAKEFILE_LIST) | sed 's/://') | |
help: ## Print this help | |
@echo 'Usage: make [target]' | |
@echo '' | |
@echo 'Targets:' | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9][a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
guard-%: | |
@ if [ "${${*}}" = "" ]; then \ | |
echo "[ERROR] Required: $* !!"; \ | |
echo "[ERROR] Please set --> $*"; \ | |
exit 1; \ | |
fi | |
branch_version := $(shell git rev-parse --abbrev-ref HEAD) | |
#------ | |
clean-package: ## Remove packages with dist. | |
rm -rf dist | |
release: clean-package ## Build and upload packages, regarding branch name as version | |
@echo '1. Update versions' | |
@sed -i -r 's/const version = ".+"/const version = "$(branch_version)"/g' {file} | |
@echo '2. Packaging' | |
@echo '3. Staging and commit' | |
git add {file} | |
git commit -m ':package: Version $(branch_version)' | |
@echo '4. Push' | |
git push | |
@echo 'Success All!!' | |
@echo 'Create a pull request and merge to master!!' | |
@echo 'https://github.com/tadashi-aikawa/gowl/compare/$(branch_version)?expand=1' | |
@echo '..And deploy package!!' | |
deploy: guard-version ## Deploy packages [Required: $version. ex. 0.5.1] | |
ghr v$(version) dist/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment