Created
August 26, 2013 09:43
-
-
Save tiennv90/6339756 to your computer and use it in GitHub Desktop.
This file contains 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
GIT_DIR = $(CURDIR)/$(shell git rev-parse --git-dir) | |
GIT_HOOKS = $(GIT_DIR)/hooks | |
GIT_HOOKS_REPO = git@github.com:NextUserSF/git-hooks.git | |
BRANCH = $(CURDIR)/$(shell git rev-parse --abbrev-ref HEAD) | |
all: | |
# Show this help message | |
help: | |
@awk 'BEGIN{print "\nMakefile usage:\n"};/^[^#[:space:]].*:/{split($$0,t,":");printf("%8s %-16s %s\n","make",t[1],x)};{gsub(/^# /,"");x=$$0;if(x!="")x="- "x};END{printf "\n"}' Makefile | |
# Init the project (run git flow, maven install, add heroku remotes) | |
init: init-git-flow | |
@if [ $(BRANCH) != "develop" ]; then \ | |
echo "You are not on branch develop. Please checkout develop."; \ | |
exit 1; \ | |
fi | |
@git remote add heroku git@heroku.com:nextuser-java-dev.git | |
@git remote add production git@heroku.com:nextuser-java-prod.git | |
@mvn clean install | |
# Install hooks | |
install-hooks: | |
@echo Installing git hooks... | |
@rm -rf git-hooks | |
@git clone $(GIT_HOOKS_REPO) | |
@cd git-hooks; ${MAKE} DESTDIR=$(GIT_HOOKS) || exit; cd .. | |
# Run Maven install | |
install: | |
@mvn clean install | |
# Run Maven package | |
build: test | |
@mvn clean package | |
# Run test suite | |
test: package | |
@echo Running tests... | |
@mvn test -DskipTest=false | |
# Run findbugs | |
bugs: package | |
@echo Running findbugs... | |
@mvn findbugs:check | |
# Run maven package | |
package: | |
@echo Building package... | |
@mvn clean package | |
# Pull rebase develop branch | |
rebase: check-git-dev check-git-dirty | |
@git pull --rebase origin develop | |
# Run test, package, push to Gitbub and Heroku dev server | |
development: check-git-dev check-git-dirty package test bugs | |
@git push origin develop | |
@git push heroku develop:master | |
# Create a new release | |
release: check-git-master check-git-dirty package test bugs | |
@echo Pushing to Github... | |
@git push origin master | |
@git push origin --tags | |
@echo Pushing to Heroku... | |
@git push production master:master | |
@git checkout develop | |
check-git-dirty: | |
@if [ -n "$(shell git status --porcelain)" ]; then \ | |
echo "Following files have uncommitted changes. Please, commit and try again."; \ | |
git status --porcelain; \ | |
exit 1; \ | |
fi | |
check-git-dev: | |
@if [ $(BRANCH) != "develop" ]; then \ | |
echo "You are not on branch develop. Please checkout develop."; \ | |
exit 1; \ | |
fi | |
check-git-master: | |
@if [ $(BRANCH) != "master" ]; then \ | |
echo "You are not on branch master. Please checkout master."; \ | |
exit 1; \ | |
fi | |
init-git-flow: | |
@if [ $(BRANCH) == "master" ]; then \ | |
git flow init | |
fi | |
.PHONY: \ | |
all \ | |
install \ | |
test \ | |
bugs \ | |
development \ | |
release \ | |
help \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment