Skip to content

Instantly share code, notes, and snippets.

@chadmayfield
Created June 2, 2019 21:19
Show Gist options
  • Save chadmayfield/a9dd44781eba1c0d89dcdfa1ac4f52a3 to your computer and use it in GitHub Desktop.
Save chadmayfield/a9dd44781eba1c0d89dcdfa1ac4f52a3 to your computer and use it in GitHub Desktop.

Revisions

  1. chadmayfield revised this gist Jun 2, 2019. No changes.
  2. chadmayfield created this gist Jun 2, 2019.
    21 changes: 21 additions & 0 deletions check_version.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    # check_version.sh - check github project for latest release version from cron & email

    url="https://github.com/USER/REPO/releases/latest"
    txt="/tmp/release.txt"
    prj="$(echo $url | awk -F "/" '{print $4 "/" $5}')"
    cmd="$(curl -sL -o /dev/null -w "%{url_effective}" ${url} | awk -F "/" '{print $NF}')"

    if [ ! -f "$txt" ]; then
    echo -n "Latest release: "
    echo "$cmd" | tee "$txt"
    else
    if ! [[ "$cmd" =~ $(cat $txt) ]]; then
    # TODO: add send email command
    echo -n "Different versions send email! Repo $prj new version: "
    echo "$cmd" | tee "$txt"
    fi
    fi

    #EOF