Created
August 11, 2016 13:54
-
-
Save leedavis81/9b241a32c121068e82f3dc678be0ad1f to your computer and use it in GitHub Desktop.
This file contains 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
tag_release=$(curl -s https://{user}:{key}@api.github.com/repos/{org}/{repo}/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name"://; s/"//; s/",$//' | xargs) | |
have_an_update() { | |
if [ ! -f "$version_file" ] | |
then | |
return 0 | |
fi | |
if [ "$(<${version_file})" != "${tag_release}" ] | |
then | |
return 0 | |
fi | |
return 1 | |
} | |
mark_update() | |
{ | |
echo $tag_release > ${version_file} | |
} | |
# If don't have an update, exit | |
if ! have_an_update | |
then | |
echo 'No updates to be applied' | |
exit | |
fi | |
// download_code, do some other stuff, switch symlinks or rsync or whatever | |
mark_update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment