xref: /aosp_15_r20/external/google-cloud-java/.kokoro/release/common.sh (revision 55e87721aa1bc457b326496a7ca40f3ea1a63287)
1#!/bin/bash
2# Copyright 2018 Google LLC
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 -eo pipefail
17
18# Get secrets from keystore and set and environment variables
19setup_environment_secrets() {
20  export GPG_PASSPHRASE=$(cat ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-passphrase)
21  export GPG_TTY=$(tty)
22  export GPG_HOMEDIR=/gpg
23  mkdir $GPG_HOMEDIR
24  mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-pubkeyring $GPG_HOMEDIR/pubring.gpg
25  mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-keyring $GPG_HOMEDIR/secring.gpg
26  export SONATYPE_USERNAME=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f1 -d'|')
27  export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f2 -d'|')
28}
29
30create_settings_xml_file() {
31  echo "<settings>
32  <servers>
33    <server>
34      <id>ossrh</id>
35      <username>${SONATYPE_USERNAME}</username>
36      <password>${SONATYPE_PASSWORD}</password>
37    </server>
38    <server>
39      <id>sonatype-nexus-staging</id>
40      <username>${SONATYPE_USERNAME}</username>
41      <password>${SONATYPE_PASSWORD}</password>
42    </server>
43    <server>
44      <id>sonatype-nexus-snapshots</id>
45      <username>${SONATYPE_USERNAME}</username>
46      <password>${SONATYPE_PASSWORD}</password>
47    </server>
48  </servers>
49</settings>" > $1
50}