Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created December 16, 2015 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neonichu/2c8dbbd7f74dfccf7202 to your computer and use it in GitHub Desktop.
Save neonichu/2c8dbbd7f74dfccf7202 to your computer and use it in GitHub Desktop.
Update used Xcode image for Travis automatically
#!/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