|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 5 | +# license agreements. See the NOTICE file distributed with |
| 6 | +# this work for additional information regarding copyright |
| 7 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 8 | +# the Apache License, Version 2.0 (the "License"); you may |
| 9 | +# not use this file except in compliance with the License. |
| 10 | +# You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, |
| 15 | +# software distributed under the License is distributed on an |
| 16 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | +# KIND, either express or implied. See the License for the |
| 18 | +# specific language governing permissions and limitations |
| 19 | +# under the License. |
| 20 | +# |
| 21 | + |
| 22 | +#see https://central.sonatype.org/publish/publish-gradle/#distributing-your-public-key |
| 23 | + |
| 24 | +set -euo pipefail |
| 25 | + |
| 26 | +if grep -sq "signing.keyId" gradle.properties; then |
| 27 | + # Keys already present |
| 28 | + exit 0 |
| 29 | +fi |
| 30 | + |
| 31 | +mkdir -p /tmp/secured |
| 32 | +keyring_file="/tmp/secured/keyring.gpg" |
| 33 | + |
| 34 | +vault_path="kv/ci-shared/release-eng/team-release-secrets/elasticsearch-java" |
| 35 | + |
| 36 | +vault kv get --field="keyring" $vault_path/gpg | base64 -d > $keyring_file |
| 37 | +## NOTE: passphase is the name of the field. |
| 38 | +signing_password=$(vault kv get --field="passphase" $vault_path/gpg) |
| 39 | +signing_key=$(vault kv get --field="key_id" $vault_path/gpg) |
| 40 | + |
| 41 | +maven_username=$(vault kv get --field="username" $vault_path/maven_central) |
| 42 | +maven_password=$(vault kv get --field="password" $vault_path/maven_central) |
| 43 | + |
| 44 | +cat >> gradle.properties <<EOF |
| 45 | +signing.keyId=${signing_key: -8} |
| 46 | +signing.password=${signing_password} |
| 47 | +signing.secretKeyRingFile=${keyring_file} |
| 48 | +
|
| 49 | +sonatypeUsername=${maven_username} |
| 50 | +sonatypePassword=${maven_password} |
| 51 | +EOF |
0 commit comments