2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-26 13:30:30 +00:00
bazel-lib/tools/copy_to_directory/mirror_release.sh
Alex Eagle 1df2becc7a chore: turn on more basic precommit checks
In particular this makes our bazelrc presets more compliant with client codebases, ensuring they can copy these files and not trip on their own pre-commit check
2023-02-17 11:00:00 -08:00

32 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Produce a dictionary for the current copy_to_directory tool release,
# suitable for adding to lib/private/copy_to_directory_toolchain.bzl
set -o errexit -o nounset -o pipefail
# Find the latest version
if [ "${1:-}" ]; then
version=$1
else
version=$(curl --silent "https://api.github.com/repos/aspect-build/bazel-lib/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
fi
# Extract the checksums and output a starlark map entry
echo "COPY_TO_DIRECTORY_VERSION = \"$version\""
echo "COPY_TO_DIRECTORY_INTEGRITY = {"
platforms=(darwin_{amd64,arm64} linux_{amd64,arm64} windows_amd64)
for release in ${platforms[@]}; do
integrity="https://github.com/aspect-build/bazel-lib/releases/download/v$version/copy_to_directory-$release"
if [[ $release == windows* ]]; then
integrity="$integrity.exe"
fi
integrity="$integrity.sha256"
curl --silent --location $integrity -o "/tmp/$release.sha256"
echo " \"$release\": \"sha256-$(cat /tmp/$release.sha256 | awk '{ print $1 }' | xxd -r -p | base64)\","
done
echo "}"
printf "\n"
echo "Paste the above into lib/private/copy_to_directory_toolchain.bzl"