Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed May 12, 2017
1 parent f0db182 commit 062a1ad
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
9 changes: 2 additions & 7 deletions main.go
Expand Up @@ -39,13 +39,8 @@ fi
if [ "${VERSION}" = "latest" ]; then
echo "Checking GitHub for latest version of ${OWNER}/${REPO}"
VERSION=$(github_api - https://api.github.com/repos/${OWNER}/${REPO}/releases/latest | grep -m 1 "\"name\":" | cut -d ":" -f 2 | tr -d ' ",')
if [ -z "${VERSION}" ]; then
echo "Unable to determine latest release for ${OWNER}/${REPO}"
exit 1
fi
VERSION=$(github_last_release "$OWNER/$REPO")
fi
# if version starts with 'v', remove it
VERSION=${VERSION#v}
Expand Down Expand Up @@ -86,7 +81,7 @@ CHECKSUM_URL=https://github.com/${OWNER}/${REPO}/releases/download/v${VERSION}/$
# Destructive operations start here
#
#
mktmpdir
TMPDIR=$(mktmpdir)
http_download ${TMPDIR}/${TARBALL} ${TARBALL_URL}
# checksum goes here
Expand Down
1 change: 1 addition & 0 deletions makeshellfn.sh
Expand Up @@ -26,6 +26,7 @@ cat \
mktmpdir.sh \
http_download.sh \
github_api.sh \
github_last_release.sh \
hash_sha256.sh \
license_end.sh | \
grep -v '^#' |grep -v ' #' | tr -s '\n'
Expand Down
19 changes: 12 additions & 7 deletions samples/godownloader-goreleaser.sh
Expand Up @@ -42,6 +42,7 @@ untar() {
mktmpdir() {
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
mkdir -p ${TMPDIR}
echo ${TMPDIR}
}
http_download() {
DEST=$1
Expand Down Expand Up @@ -76,6 +77,15 @@ github_api() {
esac
http_download $DEST $SOURCE $HEADER
}
github_last_release() {
OWNER_REPO=$1
VERSION=$(github_api - https://api.github.com/repos/${OWNER_REPO}/releases/latest | grep -m 1 "\"name\":" | cut -d ":" -f 2 | tr -d ' ",')
if [ -z "${VERSION}" ]; then
echo "Unable to determine latest release for ${OWNER_REPO}"
return 1
fi
echo ${VERSION}
}
hash_sha256() {
TARGET=${1:-$(</dev/stdin)};
if is_command gsha256sum; then
Expand Down Expand Up @@ -133,13 +143,8 @@ fi

if [ "${VERSION}" = "latest" ]; then
echo "Checking GitHub for latest version of ${OWNER}/${REPO}"
VERSION=$(github_api - https://api.github.com/repos/${OWNER}/${REPO}/releases/latest | grep -m 1 "\"name\":" | cut -d ":" -f 2 | tr -d ' ",')
if [ -z "${VERSION}" ]; then
echo "Unable to determine latest release for ${OWNER}/${REPO}"
exit 1
fi
VERSION=$(github_last_release "$OWNER/$REPO")
fi

# if version starts with 'v', remove it
VERSION=${VERSION#v}

Expand All @@ -163,7 +168,7 @@ CHECKSUM_URL=https://github.com/${OWNER}/${REPO}/releases/download/v${VERSION}/$
# Destructive operations start here
#
#
mktmpdir
TMPDIR=$(mktmpdir)
http_download ${TMPDIR}/${TARBALL} ${TARBALL_URL}

# checksum goes here
Expand Down
19 changes: 12 additions & 7 deletions samples/godownloader-hugo.sh
Expand Up @@ -42,6 +42,7 @@ untar() {
mktmpdir() {
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
mkdir -p ${TMPDIR}
echo ${TMPDIR}
}
http_download() {
DEST=$1
Expand Down Expand Up @@ -76,6 +77,15 @@ github_api() {
esac
http_download $DEST $SOURCE $HEADER
}
github_last_release() {
OWNER_REPO=$1
VERSION=$(github_api - https://api.github.com/repos/${OWNER_REPO}/releases/latest | grep -m 1 "\"name\":" | cut -d ":" -f 2 | tr -d ' ",')
if [ -z "${VERSION}" ]; then
echo "Unable to determine latest release for ${OWNER_REPO}"
return 1
fi
echo ${VERSION}
}
hash_sha256() {
TARGET=${1:-$(</dev/stdin)};
if is_command gsha256sum; then
Expand Down Expand Up @@ -133,13 +143,8 @@ fi

if [ "${VERSION}" = "latest" ]; then
echo "Checking GitHub for latest version of ${OWNER}/${REPO}"
VERSION=$(github_api - https://api.github.com/repos/${OWNER}/${REPO}/releases/latest | grep -m 1 "\"name\":" | cut -d ":" -f 2 | tr -d ' ",')
if [ -z "${VERSION}" ]; then
echo "Unable to determine latest release for ${OWNER}/${REPO}"
exit 1
fi
VERSION=$(github_last_release "$OWNER/$REPO")
fi

# if version starts with 'v', remove it
VERSION=${VERSION#v}

Expand Down Expand Up @@ -190,7 +195,7 @@ CHECKSUM_URL=https://github.com/${OWNER}/${REPO}/releases/download/v${VERSION}/$
# Destructive operations start here
#
#
mktmpdir
TMPDIR=$(mktmpdir)
http_download ${TMPDIR}/${TARBALL} ${TARBALL_URL}

# checksum goes here
Expand Down
10 changes: 10 additions & 0 deletions shellfn.go
Expand Up @@ -41,6 +41,7 @@ untar() {
mktmpdir() {
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
mkdir -p ${TMPDIR}
echo ${TMPDIR}
}
http_download() {
DEST=$1
Expand Down Expand Up @@ -75,6 +76,15 @@ github_api() {
esac
http_download $DEST $SOURCE $HEADER
}
github_last_release() {
OWNER_REPO=$1
VERSION=$(github_api - https://api.github.com/repos/${OWNER_REPO}/releases/latest | grep -m 1 "\"name\":" | cut -d ":" -f 2 | tr -d ' ",')
if [ -z "${VERSION}" ]; then
echo "Unable to determine latest release for ${OWNER_REPO}"
return 1
fi
echo ${VERSION}
}
hash_sha256() {
TARGET=${1:-$(</dev/stdin)};
if is_command gsha256sum; then
Expand Down

0 comments on commit 062a1ad

Please sign in to comment.