forked from google/jsinterop-base
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release_jsinterop_base.sh
executable file
·95 lines (81 loc) · 2.77 KB
/
release_jsinterop_base.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash -i
# Copyright 2019 Google Inc. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The script generates the open source artifacts for jsinterop.base and
# upload them to sonatype.
set -e
lib_version=$1
usage() {
echo ""
echo "$(basename $0): Build and deploy script for JsInterop Base."
echo ""
echo "$(basename $0) --version <version> [--no-deploy]"
echo " --help"
echo " Print this help output and exit."
echo " --version-file <version>"
echo " Maven version to use for deploying to sonatype."
echo " --no-deploy"
echo " Skip the deployment part but build all artifacts."
echo ""
}
deploy_flag=""
while [[ "$1" != "" ]]; do
case $1 in
--version ) if [ -z $2 ] || [[ $2 == "--no-deploy" ]]; then
echo "Error: Incorrect version value."
usage
exit 1
fi
shift
lib_version=$1
;;
--no-deploy ) deploy_flag="--no-deploy"
;;
--help ) usage
exit 1
;;
* ) echo "Error: unexpected option $1"
usage
exit 1
;;
esac
shift
done
if [[ -z "$lib_version" ]]; then
echo "Error: --version flag is missing"
usage
exit 1
fi
bazel_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
deploy_target='@com_google_j2cl//:deploy'
group_id="com.google.jsinterop"
maven_artifact="base"
cd ${bazel_root}
# ask bazel to explicitly build both jar files
bazel build //java/jsinterop/base:libbase.jar
bazel build //java/jsinterop/base:libbase-src.jar
jar_file=${bazel_root}/bazel-bin/java/jsinterop/base/libbase.jar
src_jar=${bazel_root}/bazel-bin/java/jsinterop/base/libbase-src.jar
pom_template=${bazel_root}/maven/pom-base.xml
# we cannot run the script directly from Bazel because it doesn't allow interactive script
runcmd="$(mktemp /tmp/bazel-run.XXXXXX)"
bazel run --script_path="$runcmd" ${deploy_target} -- ${deploy_flag} \
--artifact ${maven_artifact} \
--jar-file ${jar_file} \
--src-jar ${src_jar} \
--pom-template ${pom_template} \
--lib-version ${lib_version} \
--group-id ${group_id}
"$runcmd"
rm "$runcmd"