-
Notifications
You must be signed in to change notification settings - Fork 33
/
git-publish.sh
43 lines (34 loc) · 1.11 KB
/
git-publish.sh
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
#!/bin/bash
# Script to push output for npm to the `npm` branch of the repository.
# This allows to use the package as a `git` dependency by pointing at this branch
# (or a specific commit).
# Inspired by a similar script in `immutable.js`:
# https://github.com/facebook/immutable-js/blob/master/resources/gitpublish.sh
set -e
REPO=exonum/exonum-client
BOT_NAME="Travis CI"
BOT_EMAIL="ostrovski.alex@gmail.com"
rm -rf npm
git clone -b npm "https://${GH_TOKEN}@github.com/${REPO}.git" npm
rm -rf npm/* npm/.gitkeep
cp -r lib npm/
cp -r proto npm/
cp LICENSE npm/
cp README.md npm/
node -e "var package = require('./package.json'); \
delete package.scripts; \
delete package.nyc; \
delete package.devDependencies; \
require('fs').writeFileSync('./npm/package.json', JSON.stringify(package, null, 2));"
cd npm
git config user.name "${BOT_NAME}"
git config user.email "${BOT_EMAIL}"
git config push.default "simple"
git add -A .
if git diff --staged --quiet; then
echo "Nothing to publish"
else
git commit -a -m "Deploy master branch on GitHub"
git push >/dev/null 2>&1
echo "Published to npm branch of ${REPO}"
fi