1#!/bin/bash 2# Copyright 2019 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 GPG_KEY_ID=$(echo -n $(gpg --with-colons ${GPG_HOMEDIR}/pubring.gpg | awk -F':' '/pub/{ print $5 }')) 27 export SONATYPE_USERNAME=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f1 -d'|') 28 export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f2 -d'|') 29} 30 31create_settings_xml_file() { 32 echo " 33<settings> 34 <servers> 35 <server> 36 <id>ossrh</id> 37 <username>${SONATYPE_USERNAME}</username> 38 <password>${SONATYPE_PASSWORD}</password> 39 </server> 40 <server> 41 <id>sonatype-nexus-staging</id> 42 <username>${SONATYPE_USERNAME}</username> 43 <password>${SONATYPE_PASSWORD}</password> 44 </server> 45 <server> 46 <id>sonatype-nexus-snapshots</id> 47 <username>${SONATYPE_USERNAME}</username> 48 <password>${SONATYPE_PASSWORD}</password> 49 </server> 50 </servers> 51</settings>" > $1 52}