Skip to content

Instantly share code, notes, and snippets.

@leedavis81
Created August 11, 2016 13:54
Show Gist options
  • Save leedavis81/9b241a32c121068e82f3dc678be0ad1f to your computer and use it in GitHub Desktop.
Save leedavis81/9b241a32c121068e82f3dc678be0ad1f to your computer and use it in GitHub Desktop.
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