aboutsummaryrefslogtreecommitdiffstats
path: root/_release/upload.sh
blob: 8832ef83fa0be5ddd3a06c35a9b2f10e5cd749e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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
| Filename               | Version | Description        | Shasum                                   |
|:-----------------------|:--------|:-------------------|:-----------------------------------------|'

ROW_TEMPLATE="| [{{name}}]({{url}}) | $VERSION | {{description}} | {{sha}} |"


# Print header
echo "$HEADER"

for name in ${filenames[@]}; do
    bin_path="_release/bin/$name"

    # Upload file
    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}

    # Print row
    echo "$row"
done