Skip to content

Commit

Permalink
enable next update travis
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jul 29, 2017
1 parent 58af1d4 commit 1b8c08b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script:
- git --version
- git tag --sort version:refname || true
- git tag
- ./next-update-travis.sh
- npm test
after_success:
- DEBUG=github-post-release npm run semantic-release
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![Build status][ci-image] ][ci-url]
[![semantic-release][semantic-image] ][semantic-url]
[![js-standard-style][standard-image]][standard-url]
[![next-update-travis badge][nut-badge]][nut-readme]

## Problem

Expand Down Expand Up @@ -106,3 +107,5 @@ OTHER DEALINGS IN THE SOFTWARE.
[semantic-url]: https://github.com/semantic-release/semantic-release
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[standard-url]: http://standardjs.com/
[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/github-post-release.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 @@ -76,6 +76,7 @@
"license-checker": "12.0.0",
"mocha": "3.4.2",
"mockdate": "2.0.1",
"next-update-travis": "1.7.0",
"nsp": "2.6.3",
"pre-git": "3.15.0",
"prettier-standard": "6.0.0",
Expand Down

0 comments on commit 1b8c08b

Please sign in to comment.