xref: /aosp_15_r20/external/google-auth-library-java/.kokoro/release/common.sh (revision af546375c95127f07cb26dd492629ccb2e8b1be1)
1*af546375SCole Faust#!/bin/bash
2*af546375SCole Faust# Copyright 2018 Google LLC
3*af546375SCole Faust#
4*af546375SCole Faust# Licensed under the Apache License, Version 2.0 (the "License");
5*af546375SCole Faust# you may not use this file except in compliance with the License.
6*af546375SCole Faust# You may obtain a copy of the License at
7*af546375SCole Faust#
8*af546375SCole Faust#      http://www.apache.org/licenses/LICENSE-2.0
9*af546375SCole Faust#
10*af546375SCole Faust# Unless required by applicable law or agreed to in writing, software
11*af546375SCole Faust# distributed under the License is distributed on an "AS IS" BASIS,
12*af546375SCole Faust# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*af546375SCole Faust# See the License for the specific language governing permissions and
14*af546375SCole Faust# limitations under the License.
15*af546375SCole Faust
16*af546375SCole Faustset -eo pipefail
17*af546375SCole Faust
18*af546375SCole Faust# Get secrets from keystore and set and environment variables
19*af546375SCole Faustsetup_environment_secrets() {
20*af546375SCole Faust  export GPG_PASSPHRASE=$(cat ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-passphrase)
21*af546375SCole Faust  export GPG_TTY=$(tty)
22*af546375SCole Faust  export GPG_HOMEDIR=/gpg
23*af546375SCole Faust  mkdir $GPG_HOMEDIR
24*af546375SCole Faust  mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-pubkeyring $GPG_HOMEDIR/pubring.gpg
25*af546375SCole Faust  mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-keyring $GPG_HOMEDIR/secring.gpg
26*af546375SCole Faust  export SONATYPE_USERNAME=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f1 -d'|')
27*af546375SCole Faust  export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f2 -d'|')
28*af546375SCole Faust}
29*af546375SCole Faust
30*af546375SCole Faustcreate_settings_xml_file() {
31*af546375SCole Faust  echo "<settings>
32*af546375SCole Faust  <servers>
33*af546375SCole Faust    <server>
34*af546375SCole Faust      <id>ossrh</id>
35*af546375SCole Faust      <username>${SONATYPE_USERNAME}</username>
36*af546375SCole Faust      <password>${SONATYPE_PASSWORD}</password>
37*af546375SCole Faust    </server>
38*af546375SCole Faust    <server>
39*af546375SCole Faust      <id>sonatype-nexus-staging</id>
40*af546375SCole Faust      <username>${SONATYPE_USERNAME}</username>
41*af546375SCole Faust      <password>${SONATYPE_PASSWORD}</password>
42*af546375SCole Faust    </server>
43*af546375SCole Faust    <server>
44*af546375SCole Faust      <id>sonatype-nexus-snapshots</id>
45*af546375SCole Faust      <username>${SONATYPE_USERNAME}</username>
46*af546375SCole Faust      <password>${SONATYPE_PASSWORD}</password>
47*af546375SCole Faust    </server>
48*af546375SCole Faust  </servers>
49*af546375SCole Faust</settings>" > $1
50*af546375SCole Faust}