From 6777e0d2ad7f077534b493a81cfc5c2b780628b7 Mon Sep 17 00:00:00 2001 From: Jin Date: Thu, 18 Jan 2024 18:23:23 +0800 Subject: [PATCH] Fix mirror_coursier script (#1044) * Fix mirror_coursier script * Fix formatting. --- scripts/BUILD | 2 ++ scripts/mirror_coursier.sh | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/BUILD b/scripts/BUILD index 149c7cc2b..7cce40312 100644 --- a/scripts/BUILD +++ b/scripts/BUILD @@ -1,4 +1,5 @@ load("//private/rules:artifact.bzl", "artifact") +load("//private:versions.bzl", "COURSIER_CLI_HTTP_FILE_NAME") genrule( name = "buildifier-bin", @@ -17,6 +18,7 @@ sh_binary( srcs = [":mirror_coursier.sh"], data = ["@coursier_cli//file"], visibility = ["//:__pkg__"], + args = [COURSIER_CLI_HTTP_FILE_NAME], ) genrule( diff --git a/scripts/mirror_coursier.sh b/scripts/mirror_coursier.sh index 35a0ab961..8db670520 100755 --- a/scripts/mirror_coursier.sh +++ b/scripts/mirror_coursier.sh @@ -18,13 +18,14 @@ # on Google Cloud Storage for redundancy. The original artifacts are # hosted on https://github.com/coursier/coursier/releases. -set -euo pipefail +set -xeuo pipefail -readonly repo_name=$(ls external/ | grep coursier_cli_v*) -readonly coursier_cli_jar="external/$repo_name/file/downloaded" +readonly dest_filename=$1; shift; +readonly coursier_cli_jar="external/_main~_repo_rules~coursier_cli/file/downloaded" chmod u+x $coursier_cli_jar -# Upload Coursier to GCS -# -n for no-clobber, so we don't overwrite existing files -gsutil cp -n $coursier_cli_jar \ - gs://bazel-mirror/coursier_cli/$repo_name.jar +# Upload Coursier to Bazel/Google-managed GCS +# -n for no-clobber, so we don't overwrite existing files. +# -v prints the URI after a successful upload. +gsutil cp -v -n $coursier_cli_jar \ + gs://bazel-mirror/coursier_cli/$dest_filename.jar