forked from bazel-contrib/rules_oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmirror_releases_zot.sh
executable file
·32 lines (23 loc) · 1.08 KB
/
mirror_releases_zot.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
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
JQ_FILTER=\
'map({
"key": .tag_name,
"value": .assets
| map( select( (.name | startswith("zot-")) and (.name | endswith("-debug") | not) and (.name | endswith("-minimal") | not) ) )
| map({ key: .name | ltrimstr("zot-"), value: "sha256-" })
| from_entries
}) | from_entries
'
INFO="$(curl --silent -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/project-zot/zot/releases?per_page=1 | jq "$JQ_FILTER")"
# TODO: remove this for loop once https://github.com/project-zot/zot/issues/715 is fixed.
for VERSION in $(jq -r 'keys | join("\n")' <<< $INFO); do
for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<< $INFO); do
SHA256=$(curl -fLs "https://github.com/project-zot/zot/releases/download/$VERSION/zot-$PLATFORM" | sha256sum | xxd -r -p | base64)
INFO=$(jq ".[\"$VERSION\"][\"$PLATFORM\"] = \"sha256-$SHA256\"" <<< $INFO)
done
done
echo -n "ZOT_VERSIONS = "
echo $INFO | jq -M
echo ""
echo "Copy the version info into oci/private/versions.bzl"