Skip to content

Adds a script which automatically builds a #npm branch #1316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ yarn-error.log
TODO
/pages/out
/pages/generated
/npm
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ addons:
- g++-4.9

deploy:
- provider: script
skip_cleanup: true
script: npm run deploy
on:
tags: false
branch: master
repo: facebook/immutable-js
- provider: script
script: npm run gitpublish
skip_cleanup: true
on:
branch: master
repo: facebook/immutable-js
- provider: script
skip_cleanup: true
script: npm run deploy
on:
branch: master
repo: facebook/immutable-js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"test:types:flow": "flow check type-definitions/tests",
"perf": "node ./resources/bench.js",
"start": "gulp --gulpfile gulpfile.js dev",
"deploy": "(cd ./pages/out && git init && git config user.name \"Travis CI\" && git config user.email \"github@fb.com\" && git add . && git commit -m \"Deploy to GitHub Pages\" && git push --force --quiet \"https://${GH_TOKEN}@github.com/facebook/immutable-js.git\" master:gh-pages > /dev/null 2>1)"
"deploy": "(cd ./pages/out && git init && git config user.name \"Travis CI\" && git config user.email \"github@fb.com\" && git add . && git commit -m \"Deploy to GitHub Pages\" && git push --force --quiet \"https://${GH_TOKEN}@github.com/facebook/immutable-js.git\" master:gh-pages > /dev/null 2>1)",
"gitpublish": ". ./resources/gitpublish.sh"
},
"jest": {
"moduleFileExtensions": [
Expand Down
43 changes: 43 additions & 0 deletions resources/gitpublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh -e

# This script maintains a git branch which mirrors master but in a form that
# what will eventually be deployed to npm, allowing npm dependencies to use:
#
# "immutable": "git://github.com/facebook/immutable-js.git#npm"
#

# Create empty npm directory
rm -rf npm
git clone -b npm "https://${GH_TOKEN}@github.com/facebook/graphql.git" npm

# Remove existing files first
rm -rf npm/**/*

# Copy over necessary files
cp -r dist npm/
cp -r contrib npm/
cp README.md npm/
cp LICENSE npm/
cp PATENTS npm/
cp bower.json npm/

# Ensure a vanilla package.json before deploying so other tools do not interpret
# The built output as requiring any further transformation.
node -e "var package = require('./package.json'); \
delete package.scripts; \
delete package.options; \
delete package.jest; \
delete package.devDependencies; \
require('fs').writeFileSync('./npm/package.json', JSON.stringify(package, null, 2));"

cd npm
git config user.name "Travis CI"
git config user.email "github@fb.com"
git add -A .
if git diff --staged --quiet; then
echo "Nothing to publish"
else
git commit -a -m "Deploy master to NPM branch"
git push > /dev/null 2>&1
echo "Pushed"
fi