mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
docs: update releases script
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
parent
690b49b9fc
commit
f2d0c61d7c
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,7 +6,7 @@ goreleaser
|
||||
debug.test
|
||||
snap.login
|
||||
site/
|
||||
www/docs/static/releases.json
|
||||
www/docs/static/releases*.json
|
||||
.vercel
|
||||
completions/
|
||||
.vscode/
|
||||
|
@ -1,21 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
url="https://api.github.com/repos/goreleaser/goreleaser/releases"
|
||||
|
||||
get_last_page() {
|
||||
local url="$1"
|
||||
curl -sSf -I -H "Authorization: Bearer $GITHUB_TOKEN" \
|
||||
"$url" |
|
||||
grep -E '^link: ' |
|
||||
sed -e 's/^link:.*page=//g' -e 's/>.*$//g'
|
||||
sed -e 's/^link:.*page=//g' -e 's/>.*$//g' || echo "1"
|
||||
}
|
||||
|
||||
last_page="$(get_last_page)"
|
||||
tmp="$(mktemp -d)"
|
||||
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"
|
||||
curl -H "Authorization: Bearer $GITHUB_TOKEN" -sSf "$url?page=$i" >"$tmp/$i.json"
|
||||
done
|
||||
for i in $(seq 1 "$last_page"); do
|
||||
echo "page: $i"
|
||||
curl -H "Authorization: Bearer $GITHUB_TOKEN" -sSf "$url?page=$i" >"$tmp/$i.json"
|
||||
done
|
||||
|
||||
jq '[inputs] | add' "$tmp"/*.json >www/docs/static/releases.json
|
||||
if test "$last_page" -eq "1"; then
|
||||
cp -f "$tmp/1.json" "$file"
|
||||
else
|
||||
jq '[inputs] | add' "$tmp"/*.json >"$file"
|
||||
fi
|
||||
}
|
||||
|
||||
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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user