1 #!/usr/local/bin/bash 2 3 # Grab application version 4 VERSION=$(_release/bin/gdrive-osx-x64 version | awk 'NR==1 {print $2}') 5 6 declare -a filenames 7 filenames=( 8 "gdrive-osx-x64" 9 "gdrive-osx-386" 10 "gdrive-osx-arm" 11 "gdrive-linux-x64" 12 "gdrive-linux-386" 13 "gdrive-linux-rpi" 14 "gdrive-linux-arm64" 15 "gdrive-linux-arm" 16 "gdrive-linux-mips64" 17 "gdrive-linux-mips64le" 18 "gdrive-linux-ppc64" 19 "gdrive-linux-ppc64le" 20 "gdrive-windows-386.exe" 21 "gdrive-windows-x64.exe" 22 "gdrive-dragonfly-x64" 23 "gdrive-freebsd-x64" 24 "gdrive-freebsd-386" 25 "gdrive-freebsd-arm" 26 "gdrive-netbsd-x64" 27 "gdrive-netbsd-386" 28 "gdrive-netbsd-arm" 29 "gdrive-openbsd-x64" 30 "gdrive-openbsd-386" 31 "gdrive-openbsd-arm" 32 "gdrive-solaris-x64" 33 "gdrive-plan9-x64" 34 "gdrive-plan9-386" 35 ) 36 37 # Note: associative array requires bash 4+ 38 declare -A descriptions 39 descriptions=( 40 ["gdrive-osx-x64"]="OS X 64-bit" 41 ["gdrive-osx-386"]="OS X 32-bit" 42 ["gdrive-osx-arm"]="OS X arm" 43 ["gdrive-linux-x64"]="Linux 64-bit" 44 ["gdrive-linux-386"]="Linux 32-bit" 45 ["gdrive-linux-rpi"]="Linux Raspberry Pi" 46 ["gdrive-linux-arm64"]="Linux arm 64-bit" 47 ["gdrive-linux-arm"]="Linux arm 32-bit" 48 ["gdrive-linux-mips64"]="Linux mips 64-bit" 49 ["gdrive-linux-mips64le"]="Linux mips 64-bit le" 50 ["gdrive-linux-ppc64"]="Linux PPC 64-bit" 51 ["gdrive-linux-ppc64le"]="Linux PPC 64-bit le" 52 ["gdrive-windows-386.exe"]="Window 32-bit" 53 ["gdrive-windows-x64.exe"]="Windows 64-bit" 54 ["gdrive-dragonfly-x64"]="DragonFly BSD 64-bit" 55 ["gdrive-freebsd-x64"]="FreeBSD 64-bit" 56 ["gdrive-freebsd-386"]="FreeBSD 32-bit" 57 ["gdrive-freebsd-arm"]="FreeBSD arm" 58 ["gdrive-netbsd-x64"]="NetBSD 64-bit" 59 ["gdrive-netbsd-386"]="NetBSD 32-bit" 60 ["gdrive-netbsd-arm"]="NetBSD arm" 61 ["gdrive-openbsd-x64"]="OpenBSD 64-bit" 62 ["gdrive-openbsd-386"]="OpenBSD 32-bit" 63 ["gdrive-openbsd-arm"]="OpenBSD arm" 64 ["gdrive-solaris-x64"]="Solaris 64-bit" 65 ["gdrive-plan9-x64"]="Plan9 64-bit" 66 ["gdrive-plan9-386"]="Plan9 32-bit" 67 ) 68 69 # Markdown helpers 70 HEADER='### Downloads 71 | Filename | Version | Description | Shasum | 72 |:-----------------------|:--------|:-------------------|:-----------------------------------------|' 73 74 ROW_TEMPLATE="| [{{name}}]({{url}}) | $VERSION | {{description}} | {{sha}} |" 75 76 77 # Print header 78 echo "$HEADER" 79 80 for name in ${filenames[@]}; do 81 bin_path="_release/bin/$name" 82 83 # Upload file 84 url=$(gdrive upload --share $bin_path | awk '/https/ {print $7}') 85 86 # Shasum 87 sha="$(shasum -b $bin_path | awk '{print $1}')" 88 89 # Filename 90 name="$(basename $bin_path)" 91 92 # Render markdown row 93 row=${ROW_TEMPLATE//"{{name}}"/$name} 94 row=${row//"{{url}}"/$url} 95 row=${row//"{{description}}"/${descriptions[$name]}} 96 row=${row//"{{sha}}"/$sha} 97 98 # Print row 99 echo "$row" 100 done