2020-06-08 21:48:10 +02:00
|
|
|
#!/bin/bash
|
2021-02-10 21:03:30 +02:00
|
|
|
set -euo pipefail
|
2020-06-08 21:48:10 +02:00
|
|
|
|
|
|
|
get_last_page() {
|
2021-05-27 00:23:52 +02:00
|
|
|
local url="$1"
|
2021-02-10 20:48:51 +02:00
|
|
|
curl -sSf -I -H "Authorization: Bearer $GITHUB_TOKEN" \
|
2020-06-08 21:48:10 +02:00
|
|
|
"$url" |
|
2021-02-10 21:03:30 +02:00
|
|
|
grep -E '^link: ' |
|
2021-05-27 00:23:52 +02:00
|
|
|
sed -e 's/^link:.*page=//g' -e 's/>.*$//g' || echo "1"
|
2020-06-08 21:48:10 +02:00
|
|
|
}
|
|
|
|
|
2021-05-27 00:23:52 +02:00
|
|
|
generate() {
|
|
|
|
local url="$1"
|
|
|
|
local file="$2"
|
|
|
|
last_page="$(get_last_page "$url")"
|
|
|
|
tmp="$(mktemp -d)"
|
|
|
|
|
|
|
|
for i in $(seq 1 "$last_page"); do
|
|
|
|
echo "page: $i"
|
2021-11-17 05:04:04 +02:00
|
|
|
curl -H "Authorization: Bearer $GITHUB_TOKEN" -sSf "$url?page=$i" | jq 'map({tag_name: .tag_name})' >"$tmp/$i.json"
|
2021-05-27 00:23:52 +02:00
|
|
|
done
|
2020-06-08 21:48:10 +02:00
|
|
|
|
2021-05-27 00:23:52 +02:00
|
|
|
if test "$last_page" -eq "1"; then
|
2021-11-17 05:04:04 +02:00
|
|
|
cp -f "$tmp"/1.json "$file"
|
2021-05-27 00:23:52 +02:00
|
|
|
else
|
2021-11-17 05:04:04 +02:00
|
|
|
jq --compact-output -s 'add' "$tmp"/*.json >"$file"
|
2021-05-27 00:23:52 +02:00
|
|
|
fi
|
2021-07-14 19:54:33 +02:00
|
|
|
du -hs "$file"
|
2021-05-27 00:23:52 +02:00
|
|
|
}
|
2020-06-08 21:48:10 +02:00
|
|
|
|
2021-05-27 00:23:52 +02:00
|
|
|
generate "https://api.github.com/repos/goreleaser/goreleaser/releases" "www/docs/static/releases.json"
|
|
|
|
generate "https://api.github.com/repos/goreleaser/goreleaser-pro/releases" "www/docs/static/releases-pro.json"
|