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)"
|
|
|
|
|
2022-12-29 19:55:45 +02:00
|
|
|
for i in $(seq -w 1 "$last_page"); do
|
2023-01-02 20:16:33 +02:00
|
|
|
page="$(echo "$i" | awk '$0*=1')" # removes leading zeroes
|
|
|
|
echo "page: $page file: $tmp/$i.json"
|
|
|
|
curl \
|
|
|
|
-H "Authorization: Bearer $GITHUB_TOKEN" \
|
|
|
|
-sSf "$url?page=$page" |
|
|
|
|
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
|
|
|
|
2022-12-29 19:55:45 +02:00
|
|
|
jq -s 'add' "$tmp"/*.json >"$file"
|
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
|
|
|
|
2022-12-29 19:55:45 +02:00
|
|
|
latest() {
|
|
|
|
local url="$1"
|
|
|
|
local file="$2"
|
|
|
|
curl -sfL "$url/latest" | jq -r ".tag_name" >"$file"
|
|
|
|
du -hs "$file"
|
|
|
|
}
|
|
|
|
|
|
|
|
latest "https://api.github.com/repos/goreleaser/goreleaser/releases" "www/docs/static/latest"
|
|
|
|
latest "https://api.github.com/repos/goreleaser/goreleaser-pro/releases" "www/docs/static/latest-pro"
|
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"
|