Skip to content

Commit

Permalink
Fix release scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
comius committed Nov 24, 2020
1 parent 4835798 commit 6bcd18b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 32 deletions.
56 changes: 39 additions & 17 deletions src/create_java_tools_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,40 +69,62 @@ trap "rm -fr $tmp_dir" EXIT

gcs_bucket="gs://bazel-mirror/bazel_java_tools"

for platform in "_linux" "_windows" "_darwin" ""; do
rc_url="release_candidates/java/v${java_tools_version}/java_tools${platform}-v${java_tools_version}-rc${rc}.zip"
rc_sources_url="release_candidates/java/v${java_tools_version}/sources/java_tools${platform}-v${java_tools_version}-rc${rc}.zip"
for platform in "linux" "windows" "darwin"; do
rc_url="release_candidates/java/v${java_tools_version}/java_tools_${platform}-v${java_tools_version}-rc${rc}.zip"

if [[ $release == "true" ]]; then
release_artifact="releases/java/v${java_tools_version}/java_tools${platform}-v${java_tools_version}.zip"
release_sources_artifact="releases/java/v${java_tools_version}/sources/java_tools${platform}-v${java_tools_version}.zip"
release_artifact="releases/java/v${java_tools_version}/java_tools_${platform}-v${java_tools_version}.zip"
# Make release candidate the release artifact for the current platform.
# Don't overwrite existing file.
gsutil -q cp -n "${gcs_bucket}/${rc_url}" "${gcs_bucket}/${release_artifact}"

# Copy the associated zip file that contains the sources of the release zip.
# Don't overwrite existing file.
gsutil -q cp -n "${gcs_bucket}/${rc_sources_url}" "${gcs_bucket}/${release_sources_artifact}"
else
tmp_url=$(gsutil ls -lh ${gcs_bucket}/tmp/build/${commit_hash}/java/java_tools${platform}* | sort -k 2 | grep gs -m 1 | awk '{print $4}')

tmp_url=$(gsutil ls -lh ${gcs_bucket}/tmp/build/${commit_hash}/java/java_tools_${platform}* | sort -k 2 | grep gs -m 1 | awk '{print $4}')

# Make the generated artifact a release candidate for the current platform.
# Don't overwrite existing file.
gsutil -q cp -n ${tmp_url} "${gcs_bucket}/${rc_url}"
release_artifact="${rc_url}"

# Copy the associated zip file that contains the sources of the release zip.
# Don't overwrite existing file.
tmp_sources_url=$(gsutil ls -lh ${gcs_bucket}/tmp/sources/${commit_hash}/java/java_tools${platform}* | sort -k 2 | grep gs -m 1 | awk '{print $4}')
gsutil -q cp -n ${tmp_sources_url} ${gcs_bucket}/${rc_sources_url}
fi

# Download the file locally to compute its sha256sum (needed to update the
# java_tools in Bazel).
# Don't overwrite existing file.
local_zip="$tmp_dir/java_tools$platform.zip"
local_zip="$tmp_dir/java_tools_$platform.zip"
gsutil -q cp -n ${gcs_bucket}/${rc_url} ${local_zip}
file_hash=$(sha256sum ${local_zip} | cut -d' ' -f1)
echo "${release_artifact} ${file_hash}"
done

rc_url="release_candidates/java/v${java_tools_version}/java_tools-v${java_tools_version}-rc${rc}.zip"
rc_sources_url="release_candidates/java/v${java_tools_version}/sources/java_tools-v${java_tools_version}-rc${rc}.zip"

if [[ $release == "true" ]]; then
release_artifact="releases/java/v${java_tools_version}/java_tools-v${java_tools_version}.zip"
release_sources_artifact="releases/java/v${java_tools_version}/sources/java_tools-v${java_tools_version}.zip"
# Make release candidate the release artifact for the current platform.
# Don't overwrite existing file.
gsutil -q cp -n "${gcs_bucket}/${rc_url}" "${gcs_bucket}/${release_artifact}"

# Copy the associated zip file that contains the sources of the release zip.
# Don't overwrite existing file.
gsutil -q cp -n "${gcs_bucket}/${rc_sources_url}" "${gcs_bucket}/${release_sources_artifact}"
else
tmp_url=$(gsutil ls -lh ${gcs_bucket}/tmp/build/${commit_hash}/java/java_tools.* | sort -k 2 | grep gs -m 1 | awk '{print $4}')

gsutil -q cp -n ${tmp_url} "${gcs_bucket}/${rc_url}"
release_artifact="${rc_url}"

# Copy the associated zip file that contains the sources of the release zip.
# Don't overwrite existing file.
tmp_sources_url=$(gsutil ls -lh ${gcs_bucket}/tmp/sources/${commit_hash}/java/java_tools.* | sort -k 2 | grep gs -m 1 | awk '{print $4}')
gsutil -q cp -n ${tmp_sources_url} ${gcs_bucket}/${rc_sources_url}
fi

# Download the file locally to compute its sha256sum (needed to update the
# java_tools in Bazel).
# Don't overwrite existing file.
local_zip="$tmp_dir/java_tools.zip"
gsutil -q cp -n ${gcs_bucket}/${rc_url} ${local_zip}
file_hash=$(sha256sum ${local_zip} | cut -d' ' -f1)
echo "${release_artifact} ${file_hash}"

36 changes: 21 additions & 15 deletions src/upload_all_java_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ set -euo pipefail

case "$(uname -s | tr [:upper:] [:lower:])" in
msys*|mingw*|cygwin*)
declare -r is_windows=true
declare -r platform=windows
;;
linux*)
declare -r platform=linux
;;
*)
declare -r is_windows=false
declare -r platform=other
;;
esac

if "$is_windows"; then
echo Platform: $platform

if [[ "$platform" == "windows" ]]; then
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
fi
Expand All @@ -55,7 +60,7 @@ zip_path=${PWD}/bazel-bin/src/java_tools.zip
bazel build //src:java_tools_prebuilt_zip
prebuilt_zip_path=${PWD}/bazel-bin/src/java_tools_prebuilt.zip

if "$is_windows"; then
if [[ "$platform" == "windows" ]]; then
# Windows needs "file:///c:/foo/bar".
file_url="file:///$(cygpath -m ${zip_path})"
prebuilt_file_url="file:///$(cygpath -m ${prebuilt_zip_path})"
Expand All @@ -67,7 +72,7 @@ fi

# Skip for now, as the test is broken on Windows.
# See https://github.com/bazelbuild/bazel/issues/12244 for details
if ! "$is_windows"; then
if [[ "$platform" != "windows" ]]; then
for java_version in 11 14 15; do
bazel test --verbose_failures --test_output=all --nocache_test_results \
//src/test/shell/bazel:bazel_java_test_local_java_tools_jdk${java_version} \
Expand All @@ -76,18 +81,19 @@ if ! "$is_windows"; then
done
fi


bazel run //src:upload_java_tools -- \
--commit_hash ${commit_hash} \
--timestamp ${timestamp} \
--bazel_version ${bazel_version}

bazel run //src:upload_java_tools_prebuilt -- \
--commit_hash ${commit_hash} \
--timestamp ${timestamp} \
--bazel_version ${bazel_version}

bazel run //src:upload_java_tools_dist -- \
--commit_hash ${commit_hash} \
--timestamp ${timestamp} \
--bazel_version ${bazel_version}
if [[ "$platform" == "linux" ]]; then
bazel run //src:upload_java_tools -- \
--commit_hash ${commit_hash} \
--timestamp ${timestamp} \
--bazel_version ${bazel_version}

bazel run //src:upload_java_tools_dist -- \
--commit_hash ${commit_hash} \
--timestamp ${timestamp} \
--bazel_version ${bazel_version}
fi

0 comments on commit 6bcd18b

Please sign in to comment.