diff options
| -rwxr-xr-x | _release/upload.sh | 104 | 
1 files changed, 91 insertions, 13 deletions
| diff --git a/_release/upload.sh b/_release/upload.sh index ec66841..8832ef8 100755 --- a/_release/upload.sh +++ b/_release/upload.sh @@ -1,22 +1,100 @@ -#!/bin/bash +#!/usr/local/bin/bash + +# Grab application version +VERSION=$(_release/bin/gdrive-osx-x64 version | awk 'NR==1 {print $2}') + +declare -a filenames +filenames=( +    "gdrive-osx-x64" +    "gdrive-osx-386" +    "gdrive-osx-arm" +    "gdrive-linux-x64" +    "gdrive-linux-386" +    "gdrive-linux-rpi" +    "gdrive-linux-arm64" +    "gdrive-linux-arm" +    "gdrive-linux-mips64" +    "gdrive-linux-mips64le" +    "gdrive-linux-ppc64" +    "gdrive-linux-ppc64le" +    "gdrive-windows-386.exe" +    "gdrive-windows-x64.exe" +    "gdrive-dragonfly-x64" +    "gdrive-freebsd-x64" +    "gdrive-freebsd-386" +    "gdrive-freebsd-arm" +    "gdrive-netbsd-x64" +    "gdrive-netbsd-386" +    "gdrive-netbsd-arm" +    "gdrive-openbsd-x64" +    "gdrive-openbsd-386" +    "gdrive-openbsd-arm" +    "gdrive-solaris-x64" +    "gdrive-plan9-x64" +    "gdrive-plan9-386" +) + +# Note: associative array requires bash 4+ +declare -A descriptions +descriptions=( +    ["gdrive-osx-x64"]="OS X 64-bit" +    ["gdrive-osx-386"]="OS X 32-bit" +    ["gdrive-osx-arm"]="OS X arm" +    ["gdrive-linux-x64"]="Linux 64-bit" +    ["gdrive-linux-386"]="Linux 32-bit" +    ["gdrive-linux-rpi"]="Linux Raspberry Pi" +    ["gdrive-linux-arm64"]="Linux arm 64-bit" +    ["gdrive-linux-arm"]="Linux arm 32-bit" +    ["gdrive-linux-mips64"]="Linux mips 64-bit" +    ["gdrive-linux-mips64le"]="Linux mips 64-bit le" +    ["gdrive-linux-ppc64"]="Linux PPC 64-bit" +    ["gdrive-linux-ppc64le"]="Linux PPC 64-bit le" +    ["gdrive-windows-386.exe"]="Window 32-bit" +    ["gdrive-windows-x64.exe"]="Windows 64-bit" +    ["gdrive-dragonfly-x64"]="DragonFly BSD 64-bit" +    ["gdrive-freebsd-x64"]="FreeBSD 64-bit" +    ["gdrive-freebsd-386"]="FreeBSD 32-bit" +    ["gdrive-freebsd-arm"]="FreeBSD arm" +    ["gdrive-netbsd-x64"]="NetBSD 64-bit" +    ["gdrive-netbsd-386"]="NetBSD 32-bit" +    ["gdrive-netbsd-arm"]="NetBSD arm" +    ["gdrive-openbsd-x64"]="OpenBSD 64-bit" +    ["gdrive-openbsd-386"]="OpenBSD 32-bit" +    ["gdrive-openbsd-arm"]="OpenBSD arm" +    ["gdrive-solaris-x64"]="Solaris 64-bit" +    ["gdrive-plan9-x64"]="Plan9 64-bit" +    ["gdrive-plan9-386"]="Plan9 32-bit" +)  # Markdown helpers -HEADER='### Downloads' -ROW_TEMPLATE='- [{{name}}]({{url}})' +HEADER='### Downloads +| Filename               | Version | Description        | Shasum                                   | +|:-----------------------|:--------|:-------------------|:-----------------------------------------|' -# Grab application version -VERSION=$(_release/bin/drive-osx-x64 --version | awk '{print $2}' | sed -e 's/v//') +ROW_TEMPLATE="| [{{name}}]({{url}}) | $VERSION | {{description}} | {{sha}} |" -# Print markdown header + +# Print header  echo "$HEADER" -for bin_path in _release/bin/drive-*; do +for name in ${filenames[@]}; do +    bin_path="_release/bin/$name" +      # Upload file -    URL=$(drive upload --file $bin_path --share | awk '/https/ {print $9}') +    url=$(gdrive upload --share $bin_path | awk '/https/ {print $7}') + +    # Shasum +    sha="$(shasum -b $bin_path | awk '{print $1}')" + +    # Filename +    name="$(basename $bin_path)" + +    # Render markdown row +    row=${ROW_TEMPLATE//"{{name}}"/$name} +    row=${row//"{{url}}"/$url} +    row=${row//"{{description}}"/${descriptions[$name]}} +    row=${row//"{{sha}}"/$sha} -    # Render markdown row and print to screen -    NAME="$(basename $bin_path) v${VERSION}" -    ROW=${ROW_TEMPLATE//"{{name}}"/$NAME} -    ROW=${ROW//"{{url}}"/$URL} -    echo "$ROW" +    # Print row +    echo "$row"  done | 
