Skip to content

Commit

Permalink
more on issue #2 - api free way of getting github release info
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Mar 8, 2018
1 parent deece51 commit 5031695
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions github_last_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
#
# Requires: http_download, is_command
#
# hack to extract version from output is based on
#
# https://github.com/golang/dep/blob/master/install.sh
#
# 1. tr -s '\n' ' ' --> make sure output is exactly one line
# 2. sed 's/.*"tag_name":"//' --> remove everything before
# 3. sed 's/".*//' --> remove everything after
#
# what remains is the version number
#
github_last_release() {
owner_repo=$1
version=$2
test -z "$version" && version="latest"
giturl="https://github.com/${owner_repo}/releases/${version}"
html=$(http_download "-" "$giturl" "Accept:application/json")
# remove everything before tag_name:", and then everything after the next "
version=$(echo "$html" | sed 's/.*"tag_name":"//' | sed 's/".*//')
json=$(http_download "-" "$giturl" "Accept:application/json")
version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//')
test -z "$version" && return 1
echo "$version"
}

0 comments on commit 5031695

Please sign in to comment.