2022-04-22 00:45:33 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-04-20 04:45:06 +00:00
|
|
|
# Produce a dictionary for the current yq release,
|
|
|
|
# suitable for adding to lib/private/yq_toolchain.bzl
|
|
|
|
|
2022-04-22 00:45:33 +00:00
|
|
|
set -o errexit -o nounset -o pipefail
|
2022-04-20 04:45:06 +00:00
|
|
|
|
|
|
|
# Find the latest version
|
2022-04-22 00:45:33 +00:00
|
|
|
if [ "${1:-}" ]; then
|
2023-12-08 08:30:39 +00:00
|
|
|
version=$1
|
2022-04-22 00:45:33 +00:00
|
|
|
else
|
2023-12-08 08:30:39 +00:00
|
|
|
version=$(curl --silent "https://api.github.com/repos/mikefarah/yq/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
|
2022-04-22 00:45:33 +00:00
|
|
|
fi
|
2022-04-20 04:45:06 +00:00
|
|
|
|
|
|
|
# yq publishes its checksums and a script to extract them
|
2022-04-22 00:45:33 +00:00
|
|
|
curl --silent --location "https://github.com/mikefarah/yq/releases/download/v$version/extract-checksum.sh" -o /tmp/extract-checksum.sh
|
|
|
|
curl --silent --location "https://github.com/mikefarah/yq/releases/download/v$version/checksums_hashes_order" -o /tmp/checksums_hashes_order
|
|
|
|
curl --silent --location "https://github.com/mikefarah/yq/releases/download/v$version/checksums" -o /tmp/checksums
|
2022-04-20 04:45:06 +00:00
|
|
|
|
|
|
|
cd /tmp
|
|
|
|
chmod u+x extract-checksum.sh
|
|
|
|
|
|
|
|
# Extract the checksums and output a starlark map entry
|
|
|
|
echo "\"$version\": {"
|
2022-04-22 00:45:33 +00:00
|
|
|
platforms=(darwin_{amd64,arm64} linux_{amd64,arm64,s390x,ppc64le} windows_amd64)
|
|
|
|
for release in ${platforms[@]}; do
|
2023-12-08 08:30:39 +00:00
|
|
|
artifact=$release
|
|
|
|
if [[ $release == windows* ]]; then
|
|
|
|
artifact="$release.exe"
|
|
|
|
fi
|
|
|
|
echo " \"$release\": \"$(./extract-checksum.sh SHA-384 $artifact | awk '{ print $2 }' | xxd -r -p | base64 | awk '{ print "sha384-" $1 }')\","
|
2022-04-20 04:45:06 +00:00
|
|
|
done
|
|
|
|
echo "},"
|
|
|
|
|
|
|
|
printf "\n"
|
2023-02-17 18:12:41 +00:00
|
|
|
echo "Paste the above into VERSIONS in yq_toolchain.bzl."
|