Created
December 16, 2015 16:37
-
-
Save neonichu/2c8dbbd7f74dfccf7202 to your computer and use it in GitHub Desktop.
Update used Xcode image for Travis automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| function available_versions() { | |
| curl -s 'https://docs.travis-ci.com/user/languages/objective-c/'| \ | |
| grep 'osx_image: '|sed -e 's_.*<code>\(osx\_image.*\)</code>.*_\1_'|sort|uniq | |
| } | |
| function latest_version { | |
| available_versions|tail -n 1 | |
| } | |
| function used_version { | |
| cat .travis.yml|grep 'osx_image: ' | |
| } | |
| set -e | |
| if [ ! -f ".travis.yml" ] | |
| then | |
| echo "No Travis configuration found." | |
| exit 1 | |
| fi | |
| if [ -n "`git status -s`" ] | |
| then | |
| echo "Git status is not clean." | |
| exit 1 | |
| fi | |
| LATEST="`latest_version`" | |
| LATEST_IMAGE=`echo "$LATEST"|cut -d' ' -f2-` | |
| USED="`used_version`" | |
| if [ "$LATEST" != "$USED" ] | |
| then | |
| echo "Used Xcode image is outdated." | |
| branch="update-travis-to-$LATEST_IMAGE" | |
| message="Update Travis to $LATEST_IMAGE" | |
| git checkout -b "$branch" | |
| sed -i '' -e "s/^$USED$/$LATEST/" .travis.yml | |
| git add .travis.yml | |
| git commit -m "$message" | |
| git push -u origin "$branch" | |
| url=`hub pull-request -m "$message"` | |
| open $url | |
| git checkout master | |
| git branch -D "$branch" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment