iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2019 The Bazel Authors. All rights reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # A script to upload a given java_tools zip on GCS. Used by the java_tools_binaries |
| 18 | # Buildkite pipeline. It is not recommended to run this script manually. |
iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 19 | |
| 20 | # Script used by the "java_tools binaries" Buildkite pipeline to build the java tools archives |
| 21 | # and upload them on GCS. |
| 22 | # |
| 23 | # The script has to be executed directly without invoking bazel: |
| 24 | # $ src/upload_all_java_tools.sh |
| 25 | # |
| 26 | # The script cannot be invoked through a sh_binary using bazel because git |
| 27 | # cannot be used through a sh_binary. |
| 28 | |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 29 | set -euo pipefail |
| 30 | |
| 31 | case "$(uname -s | tr [:upper:] [:lower:])" in |
| 32 | msys*|mingw*|cygwin*) |
| 33 | declare -r is_windows=true |
| 34 | ;; |
| 35 | *) |
| 36 | declare -r is_windows=false |
| 37 | ;; |
| 38 | esac |
| 39 | |
| 40 | if "$is_windows"; then |
| 41 | export MSYS_NO_PATHCONV=1 |
| 42 | export MSYS2_ARG_CONV_EXCL="*" |
| 43 | fi |
| 44 | |
iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 45 | commit_hash=$(git rev-parse HEAD) |
| 46 | timestamp=$(date +%s) |
| 47 | bazel_version=$(bazel info release | cut -d' ' -f2) |
| 48 | |
| 49 | # Passing the same commit_hash and timestamp to all targets to mark all the artifacts |
| 50 | # uploaded on GCS with the same identifier. |
Ivo List | 389e0da | 2020-09-29 03:59:35 -0700 | [diff] [blame] | 51 | for java_version in 11; do |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 52 | |
| 53 | bazel build //src:java_tools_java${java_version}_zip |
| 54 | zip_path=${PWD}/bazel-bin/src/java_tools_java${java_version}.zip |
| 55 | |
| 56 | if "$is_windows"; then |
| 57 | # Windows needs "file:///c:/foo/bar". |
| 58 | file_url="file:///$(cygpath -m ${zip_path})" |
| 59 | else |
| 60 | # Non-Windows needs "file:///foo/bar". |
| 61 | file_url="file://${zip_path}" |
| 62 | fi |
Ivo List | 23c4406 | 2020-10-19 07:30:47 -0700 | [diff] [blame] | 63 | |
| 64 | # Skip for now, as the test is broken on Windows. |
| 65 | # See https://github.com/bazelbuild/bazel/issues/12244 for details |
| 66 | if not "$is_windows"; then |
| 67 | bazel test --verbose_failures --test_output=all --nocache_test_results \ |
| 68 | //src/test/shell/bazel:bazel_java_test_local_java_tools_jdk${java_version} \ |
| 69 | --define=LOCAL_JAVA_TOOLS_ZIP_URL="${file_url}" |
| 70 | fi |
iirina | 1df1635 | 2019-05-09 05:48:58 -0700 | [diff] [blame] | 71 | |
| 72 | bazel run //src:upload_java_tools_java${java_version} -- \ |
| 73 | --java_tools_zip src/java_tools_java${java_version}.zip \ |
| 74 | --commit_hash ${commit_hash} \ |
| 75 | --timestamp ${timestamp} \ |
| 76 | --bazel_version ${bazel_version} |
| 77 | |
| 78 | bazel run //src:upload_java_tools_dist_java${java_version} -- \ |
| 79 | --commit_hash ${commit_hash} \ |
| 80 | --timestamp ${timestamp} \ |
| 81 | --bazel_version ${bazel_version} |
iirina | e277b0c | 2019-04-16 05:25:01 -0700 | [diff] [blame] | 82 | done |