-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
83 lines (67 loc) · 2.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
SHELL:=bash
BUNDLE?=./node_modules/.bin/browserify
JSHINT?=./node_modules/.bin/jshint
DOCCO?=./node_modules/.bin/docco
define assert_no_local_changes
@git --no-pager diff --exit-code --quiet || \
(echo "You must commit or stash your changes first" 1>&2 && \
exit 1)
@git --no-pager diff --exit-code --quiet --cached || \
(echo "You must commit your staged changes first" 1>&2 && \
exit 1)
endef
define assert_master_branch
@git rev-parse --abbrev-ref HEAD \
| grep 'master' > /dev/null 2>&1 || \
(echo "You must be on the master branch" 1>&2 && \
exit 1)
endef
define assert_remote
@git remote -v | grep origin | \
grep "7digital/7digital-api" > /dev/null 2>&1 || \
(echo "Your origin must be the source repository " \
"7digital/7digital-api" && exit 1)
endef
define assert_all_changes_pushed
test -z "`git rev-list @{upstream}.. -n 1`" || \
(echo "You must push all your changes first" 1>&2 && \
exit 1)
endef
define assert_is_owner
npm --registry=http://registry.npmjs.org --loglevel=warn owner ls | \
awk '{print $1}' | \
grep "`npm whoami`" > /dev/null 2>&1 || \
(echo "You must be an owner to publish" 1>&2 && \
exit 1)
endef
test: check
@npm test
check:
$(JSHINT) lib/*.js examples/*.js
bundle:
$(BUNDLE) build.js > build/7digital.js
docs:
$(DOCCO) --layout linear {lib,examples}/*.js
publish-check:
$(assert_remote)
$(assert_master_branch)
$(assert_no_local_changes)
publish-docs: test docs publish-check
git checkout gh-pages
git pull --rebase origin gh-pages
rm *.{html,css}
rm -rf public
cp -R docs/* .
git add -A
-git commit -m "Publish docs"
git push origin gh-pages
git checkout master
publish: publish-docs
test -n "$(version)" || (echo \
"Supply a version: make publish version=x.x.x" && \
exit 1)
$(assert_is_owner)
npm version $(version) --registry=http://registry.npmjs.org
git push origin master --tags
npm publish --registry=http://registry.npmjs.org
.PHONY: test check docs build publish-docs publish