Skip to content

Commit 14a2fd0

Browse files
committed
[chore] improving build and publish pipeline.
1 parent cb799d3 commit 14a2fd0

File tree

10 files changed

+124
-22
lines changed

10 files changed

+124
-22
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ examples/**/*-bundle.js
22
node_modules/
33
.idea/
44
_book
5+
coverage/*
6+
*.patch
7+
*.diff
8+
examples/__build__

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ node_js:
77
before_script:
88
- export DISPLAY=:99.0
99
- sh -e /etc/init.d/xvfb start
10+
script:
11+
- make tests-ci

Diff for: Makefile

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
NODE=$(shell which node)
2+
NPM=$(shell which npm)
3+
YARN=$(shell which yarn)
4+
JQ=$(shell which jq)
5+
6+
VERSION=$(shell jq ".version" package.json)
7+
8+
help: info
9+
@echo
10+
@echo "List of commands:"
11+
@echo
12+
@echo " make info - display node, npm and yarn versions..."
13+
@echo " make deps - install all dependencies."
14+
@echo " make serve - start the server."
15+
@echo " make tests - run tests."
16+
@echo " make docs - build and serve the docs."
17+
@echo " make build - build project artifacts."
18+
@echo " make publish - build and publish version on npm."
19+
@echo " make publish-docs - build the docs and publish to gh-pages."
20+
@echo " make publish-all - publish version and docs."
21+
22+
info:
23+
@echo node version: `$(NODE) --version` "($(NODE))"
24+
@echo npm version: `$(NPM) --version` "($(NPM))"
25+
@echo yarn version: `$(YARN) --version` "($(YARN))"
26+
@echo jq version: `$(JQ) --version` "($(JQ))"
27+
@echo react-modal version: $(VERSION)
28+
29+
deps:
30+
@[[ ! -z "$(YARN)" ]] && $(YARN) install || $(NPM) install
31+
@gitbook install
32+
33+
# Rules for development
34+
35+
serve:
36+
@npm start
37+
38+
tests:
39+
@npm run test
40+
41+
tests-ci:
42+
@npm run test -- --single-run
43+
44+
docs: build-docs
45+
gitbook serve
46+
47+
# Rules for build and publish
48+
49+
build:
50+
@echo "[Building dists]"
51+
@./node_modules/.bin/webpack --config webpack.dist.config.js
52+
53+
build-docs:
54+
@echo "[Building documentation]"
55+
@rm -rf _book/*
56+
@gitbook build -g reactjs/react-modal
57+
58+
version:
59+
@echo "[Updating react-modal version]"
60+
@sh ./scripts/version $(VERSION)
61+
62+
release-commit:
63+
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
64+
git commit --allow-empty -m "Release v`cat .version`."
65+
@rm .version
66+
git add .
67+
git commit --amend -m "`git log -1 --format=%s`"
68+
69+
release-tag:
70+
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
71+
git tag "v`cat .version`"
72+
@rm .version
73+
74+
publish-version: release-commit release-tag
75+
@echo "[Publishing]"
76+
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
77+
git push [email protected]:reactjs/react-modal "`git branch | grep '^*' | awk '{ print $$2 }'`" "v`cat .version`"
78+
npm publish
79+
@rm .version
80+
81+
publish: version build publish-version publish-finished
82+
83+
publish-docs: build-docs
84+
@echo "[Publishing docs]"
85+
cd _book
86+
git init
87+
git commit --allow-empty -m 'update book'
88+
git checkout -b gh-pages
89+
touch .nojekyll
90+
git add .
91+
git commit -am 'update book'
92+
git push [email protected]:reactjs/react-modal gh-pages --force
93+
cd ..
94+
95+
publish-all: publish publish-docs

Diff for: package.json

+3-10
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,8 @@
1313
"example": "examples"
1414
},
1515
"scripts": {
16-
"test": "NODE_ENV=test karma start",
17-
"start": "scripts/dev-examples",
18-
"docs": "npm-run-all docs:*",
19-
"docs-dev": "npm-run-all docs:clean docs:prepare docs:build:watch",
20-
"docs:clean": "rimraf _book",
21-
"docs:prepare": "gitbook install",
22-
"docs:build": "gitbook build -g reactjs/react-modal",
23-
"docs:build:watch": "gitbook serve",
24-
"docs:publish": "cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push [email protected]:reactjs/react-modal gh-pages --force"
16+
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
17+
"test": "NODE_ENV=test karma start"
2518
},
2619
"authors": [
2720
"Ryan Florence"
@@ -77,4 +70,4 @@
7770
"modal",
7871
"dialog"
7972
]
80-
}
73+
}

Diff for: scripts/build

-2
This file was deleted.

Diff for: scripts/dev-examples

-3
This file was deleted.

Diff for: scripts/preview-release

-2
This file was deleted.

Diff for: scripts/release

-3
This file was deleted.

Diff for: scripts/test

-2
This file was deleted.

Diff for: scripts/version

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
JQ=$(which jq)
4+
5+
if [[ -z "$JQ" ]]; then
6+
echo "jq is missing."
7+
fi
8+
9+
echo "Current version is: $1"
10+
11+
read -p "Bump to: " NEW_VERSION
12+
13+
FILES="package.json bower.json"
14+
15+
for F in $FILES; do
16+
$JQ ".version = \"${NEW_VERSION}\"" "$F" > up.json
17+
cat up.json > "$F"
18+
done
19+
20+
rm up.json

0 commit comments

Comments
 (0)