-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-versions.sh
executable file
·158 lines (135 loc) · 3.68 KB
/
latest-versions.sh
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# This script gets the latest GitHub releases for the specified projects.
if [[ -z "$GITHUB_TOKEN" ]]; then
echo "Set the GITHUB_TOKEN env variable."
exit 1
fi
URI=https://api.github.com
API_VERSION=v3
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
get_latest() {
local repo=$1
local resp
resp=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${repo}/releases")
local tag
tag=$(echo "$resp" | jq -e --raw-output .[0].tag_name)
local name
name=$(echo "$resp" | jq -e --raw-output .[0].name)
if [[ "$tag" == "null" ]]; then
# get the latest tag
resp=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${repo}/tags")
tag=$(echo "$resp" | jq -e --raw-output .[0].name)
tag=${tag#release-}
fi
if [[ "$name" == "null" ]] || [[ "$name" == "" ]]; then
name="-"
fi
local dir=${repo#*/}
# Change to upper case for grep
local udir
udir=$(echo $dir | awk '{print toupper($0)}')
# Replace dashes (-) with underscores (_)
udir=${udir//-/_}
udir=${udir%/*}
if [[ "$dir" == "wireguard-tools" ]]; then
dir="wireguard/install"
udir="WIREGUARD_TOOLS"
elif [[ "$dir" == "wireguard-linux-compat" ]]; then
dir="wireguard/install"
udir="WIREGUARD"
fi
local current
if [[ ! -d "$dir" ]]; then
# If the directory does not exist, then grep all for it
current=$(grep -m 1 "${udir}_VERSION" -- **/Dockerfile | head -n 1 | awk '{print $(NF)}')
else
current=$(grep -m 1 "${udir}_VERSION" "${dir}/Dockerfile" | awk '{print $(NF)}')
fi
compare "$name" "$dir" "$tag" "$current" "https://github.com/${repo}/releases"
}
get_latest_unifi() {
local latest current
latest=$(curl -sSL http://www.ubnt.com/downloads/unifi/debian/dists/cloudkey-stable/ubiquiti/binary-armhf/Packages \
| awk 'BEGIN {FS="\n"; RS="";} /^Package: unifi/' \
| awk '/^Version:/ {print $2}' \
| cut -d- -f1)
current=$(grep -m 1 UNIFI_VERSION unifi/Dockerfile | tr '"' ' ' | awk '{print $(NF)}')
compare unifi unifi "$latest" "$current" https://www.ubnt.com/download/unifi
}
compare() {
local name="$1" dir="$2" tag="$3" current="$4" releases="$5"
ignore_dirs=( "mc" "zookeeper/3.6" )
if [[ "$tag" =~ $current ]] || [[ "$name" =~ $current ]] || [[ "$current" =~ $tag ]] || [[ "$current" == "master" ]]; then
echo -e "\\e[36m${dir}:\\e[39m current ${current} | ${tag} | ${name}"
else
# add to the bad versions
if [[ ! " ${ignore_dirs[*]} " =~ ${dir} ]]; then
bad_versions+=( "${dir}" )
fi
echo -e "\\e[31m${dir}:\\e[39m current ${current} | ${tag} | ${name} | ${releases}"
fi
}
projects=(
iovisor/bcc
iovisor/bpftrace
certbot/certbot
cloudflare/cfssl
quay/clair
hashicorp/consul
coredns/coredns
curl/curl
kolide/fleet
google/gitiles
google/guetzli
irssi/irssi
cryptodotis/irssi-otr
keepassxreboot/keepassxc
robertdavidgraham/masscan
MidnightCommander/mc
zyedidia/micro
mitmproxy/mitmproxy
hashicorp/nomad
nzbget/nzbget
pusher/oauth2_proxy
facebook/osquery
hashicorp/packer
Tautulli/Tautulli
perkeep/perkeep
pomerium/pomerium
powershell/powershell
cesanta/docker_auth
ricochet-im/ricochet
rstudio/rstudio
tarsnap/tarsnap
maxmind/libmaxminddb
hashicorp/terraform
kdlucas/byte-unixbench
mitchellh/vagrant
hashicorp/vault
containrrr/watchtower
wireguard/wireguard-tools
wireguard/wireguard-linux-compat
znc/znc
tianon/gosu
)
other_projects=(
unifi
)
bad_versions=()
main() {
# shellcheck disable=SC2068
for p in ${projects[@]}; do
get_latest "$p"
done
# shellcheck disable=SC2068
for p in ${other_projects[@]}; do
get_latest_"$p"
done
if [[ ${#bad_versions[@]} -ne 0 ]]; then
echo
echo "These Dockerfiles are not up to date: ${bad_versions[*]}" >&2
exit 1
fi
}
main