Skip to content

Commit

Permalink
chore(ci): add next-update-travis, close #110
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jul 31, 2017
1 parent d246897 commit b8d319a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ before_install:
before_script:
- npm prune
script:
- ./next-update-travis.sh
- npm test
- echo Testing default end to end behavior
- npm run e2e
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
[![devdependencies][pre-git-devdependencies-image]][pre-git-devdependencies-url]
[![semantic-release][semantic-image] ][semantic-url]
[![manpm](https://img.shields.io/badge/manpm-%E2%9C%93-3399ff.svg)](https://github.com/bahmutov/manpm)

[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-url]: https://github.com/semantic-release/semantic-release
[![next-update-travis badge][nut-badge]][nut-readme]

## Why?

Expand Down Expand Up @@ -312,3 +310,7 @@ Support: if you find any problems with this module, email / tweet /
[pre-git-dependencies-url]: https://david-dm.org/bahmutov/pre-git
[pre-git-devdependencies-image]: https://david-dm.org/bahmutov/pre-git/dev-status.svg
[pre-git-devdependencies-url]: https://david-dm.org/bahmutov/pre-git#info=devDependencies
[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-url]: https://github.com/semantic-release/semantic-release
[nut-badge]: https://img.shields.io/badge/next--update--travis-ok-green.svg
[nut-readme]: https://github.com/bahmutov/next-update-travis#readme
55 changes: 55 additions & 0 deletions next-update-travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -e

if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then
if [ "$GH_TOKEN" = "" ]; then
echo ""
echo "⛔️ Cannot find environment variable GH_TOKEN ⛔️"
echo "Please set it up for this script to be able"
echo "to push results to GitHub"
echo "ℹ️ The best way is to use semantic-release to set it up"
echo ""
echo " https://github.com/semantic-release/semantic-release"
echo ""
echo "npm i -g semantic-release-cli"
echo "semantic-release-cli setup"
echo ""
exit 1
fi

echo "Upgrading dependencies using next-update"
npm i -g next-update

# you can edit options to allow only some updates
# --allow major | minor | patch
# --latest true | false
# see all options by installing next-update
# and running next-update -h
next-update --allow minor --latest false

git status
# if package.json is modified we have
# new upgrades
if git diff --name-only | grep package.json > /dev/null; then
echo "There are new versions of dependencies 💪"
git add package.json
echo "----------- package.json diff -------------"
git diff --staged
echo "-------------------------------------------"
git config --global user.email "next-update@ci.com"
git config --global user.name "next-update"
git commit -m "chore(deps): upgrade dependencies using next-update"
# push back to GitHub using token
git remote remove origin
# TODO read origin from package.json
# or use github api module github
# like in https://github.com/semantic-release/semantic-release/blob/caribou/src/post.js
git remote add origin https://next-update:$GH_TOKEN@github.com/bahmutov/pre-git.git
git push origin HEAD:master
else
echo "No new versions found ✋"
fi
else
echo "Not a cron job, normal test"
fi
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"jshint-summary": "0.4.0",
"matchdep": "1.0.1",
"mocha": "3.4.2",
"next-update-travis": "1.7.0",
"semantic-release": "6.3.6"
},
"engines": {
Expand Down

0 comments on commit b8d319a

Please sign in to comment.