xref: /aosp_15_r20/external/jazzer-api/deploy/deploy.sh (revision 33edd6723662ea34453766bfdca85dbfdd5342b8)
1#!/usr/bin/env sh
2# Copyright 2022 Code Intelligence GmbH
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -eu
17
18fail() {
19  echo "$1"
20  exit 1
21}
22
23cd "$BUILD_WORKSPACE_DIRECTORY" || fail "BUILD_WORKSPACE_DIRECTORY not found"
24
25JAZZER_COORDINATES=$1
26
27[ -z "${MAVEN_USER+x}" ] && \
28  fail "Set MAVEN_USER to the Sonatype OSSRH user"
29[ -z "${MAVEN_PASSWORD+x}" ] && \
30  fail "Set MAVEN_PASSWORD to the Sonatype OSSRH password"
31[ -z "${JAZZER_JAR_PATH+x}" ] && \
32  fail "Set JAZZER_JAR_PATH to the absolute path of jazzer.jar obtained from the release GitHub Actions workflow"
33[ ! -f "${JAZZER_JAR_PATH}" ] && \
34  fail "JAZZER_JAR_PATH does not exist at '$JAZZER_JAR_PATH'"
35
36MAVEN_REPO=https://oss.sonatype.org/service/local/staging/deploy/maven2
37
38# The Jazzer jar itself bundles native libraries for multiple architectures and thus can't be built
39# on the local machine. It is obtained from CI and passed in via JAZZER_JAR_PATH.
40bazel build //deploy:jazzer-docs //deploy:jazzer-sources //deploy:jazzer-pom
41
42JAZZER_DOCS_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-docs)
43JAZZER_SOURCES_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-sources)
44JAZZER_POM_PATH=$PWD/$(bazel cquery --output=files //deploy:jazzer-pom)
45
46bazel run --define "maven_repo=${MAVEN_REPO}" --define "maven_user=${MAVEN_USER}" \
47  --define "maven_password=${MAVEN_PASSWORD}" --define gpg_sign=true \
48  //deploy:jazzer-api.publish
49bazel run @rules_jvm_external//private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:MavenPublisher -- \
50  "$MAVEN_REPO" true "$MAVEN_USER" "$MAVEN_PASSWORD" "$JAZZER_COORDINATES" \
51  "$JAZZER_POM_PATH" "$JAZZER_JAR_PATH" "$JAZZER_SOURCES_PATH" "$JAZZER_DOCS_PATH"
52bazel run --define "maven_repo=${MAVEN_REPO}" --define "maven_user=${MAVEN_USER}" \
53  --define "maven_password=${MAVEN_PASSWORD}" --define gpg_sign=true \
54  //deploy:jazzer-junit.publish
55