Skip to content

Commit

Permalink
[chore] improving build and publish pipeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
diasbruno committed Jun 8, 2017
1 parent cb799d3 commit 14a2fd0
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ examples/**/*-bundle.js
node_modules/
.idea/
_book
coverage/*
*.patch
*.diff
examples/__build__
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ node_js:
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- make tests-ci
95 changes: 95 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
NODE=$(shell which node)
NPM=$(shell which npm)
YARN=$(shell which yarn)
JQ=$(shell which jq)

VERSION=$(shell jq ".version" package.json)

help: info
@echo
@echo "List of commands:"
@echo
@echo " make info - display node, npm and yarn versions..."
@echo " make deps - install all dependencies."
@echo " make serve - start the server."
@echo " make tests - run tests."
@echo " make docs - build and serve the docs."
@echo " make build - build project artifacts."
@echo " make publish - build and publish version on npm."
@echo " make publish-docs - build the docs and publish to gh-pages."
@echo " make publish-all - publish version and docs."

info:
@echo node version: `$(NODE) --version` "($(NODE))"
@echo npm version: `$(NPM) --version` "($(NPM))"
@echo yarn version: `$(YARN) --version` "($(YARN))"
@echo jq version: `$(JQ) --version` "($(JQ))"
@echo react-modal version: $(VERSION)

deps:
@[[ ! -z "$(YARN)" ]] && $(YARN) install || $(NPM) install
@gitbook install

# Rules for development

serve:
@npm start

tests:
@npm run test

tests-ci:
@npm run test -- --single-run

docs: build-docs
gitbook serve

# Rules for build and publish

build:
@echo "[Building dists]"
@./node_modules/.bin/webpack --config webpack.dist.config.js

build-docs:
@echo "[Building documentation]"
@rm -rf _book/*
@gitbook build -g reactjs/react-modal

version:
@echo "[Updating react-modal version]"
@sh ./scripts/version $(VERSION)

release-commit:
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
git commit --allow-empty -m "Release v`cat .version`."
@rm .version
git add .
git commit --amend -m "`git log -1 --format=%s`"

release-tag:
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
git tag "v`cat .version`"
@rm .version

publish-version: release-commit release-tag
@echo "[Publishing]"
@$(JQ) '.version' package.json | cut -d\" -f2 > .version
git push [email protected]:reactjs/react-modal "`git branch | grep '^*' | awk '{ print $$2 }'`" "v`cat .version`"
npm publish
@rm .version

publish: version build publish-version publish-finished

publish-docs: build-docs
@echo "[Publishing docs]"
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
cd ..

publish-all: publish publish-docs
13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,8 @@
"example": "examples"
},
"scripts": {
"test": "NODE_ENV=test karma start",
"start": "scripts/dev-examples",
"docs": "npm-run-all docs:*",
"docs-dev": "npm-run-all docs:clean docs:prepare docs:build:watch",
"docs:clean": "rimraf _book",
"docs:prepare": "gitbook install",
"docs:build": "gitbook build -g reactjs/react-modal",
"docs:build:watch": "gitbook serve",
"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"
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
"test": "NODE_ENV=test karma start"
},
"authors": [
"Ryan Florence"
Expand Down Expand Up @@ -77,4 +70,4 @@
"modal",
"dialog"
]
}
}
2 changes: 0 additions & 2 deletions scripts/build

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/dev-examples

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/preview-release

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/release

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/test

This file was deleted.

20 changes: 20 additions & 0 deletions scripts/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

JQ=$(which jq)

if [[ -z "$JQ" ]]; then
echo "jq is missing."
fi

echo "Current version is: $1"

read -p "Bump to: " NEW_VERSION

FILES="package.json bower.json"

for F in $FILES; do
$JQ ".version = \"${NEW_VERSION}\"" "$F" > up.json
cat up.json > "$F"
done

rm up.json

0 comments on commit 14a2fd0

Please sign in to comment.