Skip to content

Commit 7941cc5

Browse files
authored
feat: Add scripts to release gapic-generator-java as jar (#1111)
1 parent 402d565 commit 7941cc5

13 files changed

+816
-6
lines changed

.github/release-please.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
releaseType: simple
1+
releaseType: java-yoshi
2+
bumpMinorPreMajor: true
23
handleGHRelease: true
34
primaryBranch: main

.kokoro/common.cfg

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR}
4+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
5+
6+
# All builds use the trampoline script to run in docker.
7+
build_file: "gapic-generator-java/.kokoro/trampoline.sh"
8+
9+
# Tell the trampoline which build file to use.
10+
env_vars: {
11+
key: "TRAMPOLINE_BUILD_FILE"
12+
value: "github/gapic-generator-java/.kokoro/build.sh"
13+
}

.kokoro/populate-secrets.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Copyright 2020 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+
16+
set -eo pipefail
17+
18+
function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
19+
function msg { println "$*" >&2 ;}
20+
function println { printf '%s\n' "$(now) $*" ;}
21+
22+
23+
# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
24+
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
25+
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
26+
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
27+
mkdir -p ${SECRET_LOCATION}
28+
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
29+
do
30+
msg "Retrieving secret ${key}"
31+
docker run --entrypoint=gcloud \
32+
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
33+
gcr.io/google.com/cloudsdktool/cloud-sdk \
34+
secrets versions access latest \
35+
--project cloud-devrel-kokoro-resources \
36+
--secret ${key} > \
37+
"${SECRET_LOCATION}/${key}"
38+
if [[ $? == 0 ]]; then
39+
msg "Secret written to ${SECRET_LOCATION}/${key}"
40+
else
41+
msg "Error retrieving secret ${key}"
42+
fi
43+
done

.kokoro/release/common.cfg

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Download trampoline resources.
4+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
5+
6+
# Use the trampoline script to run in docker.
7+
build_file: "gapic-generator-java/.kokoro/trampoline.sh"
8+
9+
# Configure the docker image for kokoro-trampoline.
10+
env_vars: {
11+
key: "TRAMPOLINE_IMAGE"
12+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
13+
}
14+
15+
before_action {
16+
fetch_keystore {
17+
keystore_resource {
18+
keystore_config_id: 70247
19+
keyname: "maven-gpg-keyring"
20+
}
21+
}
22+
}
23+
24+
before_action {
25+
fetch_keystore {
26+
keystore_resource {
27+
keystore_config_id: 70247
28+
keyname: "maven-gpg-passphrase"
29+
}
30+
}
31+
}
32+
33+
before_action {
34+
fetch_keystore {
35+
keystore_resource {
36+
keystore_config_id: 70247
37+
keyname: "maven-gpg-pubkeyring"
38+
}
39+
}
40+
}
41+
42+
before_action {
43+
fetch_keystore {
44+
keystore_resource {
45+
keystore_config_id: 70247
46+
keyname: "sonatype-credentials"
47+
}
48+
}
49+
}

.kokoro/release/common.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
16+
set -eo pipefail
17+
18+
# Get secrets from keystore and set and environment variables
19+
setup_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+
31+
create_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+
}

.kokoro/release/stage.cfg

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
env_vars: {
3+
key: "TRAMPOLINE_BUILD_FILE"
4+
value: "github/gapic-generator-java/.kokoro/release/stage.sh"
5+
}
6+
7+
action {
8+
define_artifacts {
9+
regex: "github/gapic-generator-java/target/nexus-staging/staging/*.properties"
10+
strip_prefix: "github/gapic-generator-java"
11+
}
12+
}
13+
14+
env_vars: {
15+
key: "SECRET_MANAGER_KEYS"
16+
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
17+
}

.kokoro/release/stage.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
16+
set -eo pipefail
17+
18+
if [[ -n "${AUTORELEASE_PR}" ]]
19+
then
20+
# Start the releasetool reporter
21+
requirementsFile=$(realpath $(dirname "${BASH_SOURCE[0]}")/../requirements.txt)
22+
python3 -m pip install --require-hashes -r $requirementsFile
23+
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
24+
fi
25+
26+
source $(dirname "$0")/common.sh
27+
MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml
28+
pushd $(dirname "$0")/../../
29+
30+
setup_environment_secrets
31+
create_settings_xml_file "settings.xml"
32+
33+
mvn clean deploy -B \
34+
-DskipTests=true \
35+
-Dclirr.skip=true \
36+
--settings ${MAVEN_SETTINGS_FILE} \
37+
-Dgpg.executable=gpg \
38+
-Dgpg.passphrase=${GPG_PASSPHRASE} \
39+
-Dgpg.homedir=${GPG_HOMEDIR} \
40+
-P release
41+
42+
# The job triggered by Release Please (release-trigger) has this AUTORELEASE_PR
43+
# environment variable. Fusion also lets us to specify this variable.
44+
if [[ -n "${AUTORELEASE_PR}" ]]
45+
then
46+
mvn nexus-staging:release -B \
47+
-P release-staging-repository \
48+
-DperformRelease=true \
49+
--settings=${MAVEN_SETTINGS_FILE}
50+
else
51+
echo "AUTORELEASE_PR is not set. Not releasing."
52+
fi

.kokoro/requirements.in

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
gcp-docuploader==0.6.3
2+
google-crc32c==1.3.0
3+
googleapis-common-protos==1.56.3
4+
gcp-releasetool==1.9.1
5+
cryptography==38.0.3
6+
cachetools==4.2.4
7+
cffi==1.15.1
8+
jeepney==0.7.1
9+
jinja2==3.0.3
10+
markupsafe==2.0.1
11+
keyring==23.4.1
12+
packaging==21.3
13+
protobuf==3.19.5
14+
pyjwt==2.4.0
15+
pyparsing==3.0.9
16+
pycparser==2.21
17+
pyperclip==1.8.2
18+
python-dateutil==2.8.2
19+
requests==2.27.1
20+
certifi==2022.9.24
21+
importlib-metadata==4.8.3
22+
zipp==3.6.0
23+
google_api_core==2.8.2
24+
google-cloud-storage==2.0.0
25+
google-resumable-media==2.3.3
26+
google-cloud-core==2.3.1
27+
typing-extensions==4.1.1
28+
urllib3==1.26.12
29+
zipp==3.6.0
30+
rsa==4.9
31+
six==1.16.0
32+
attrs==22.1.0
33+
google-auth==2.14.1
34+
idna==3.4

0 commit comments

Comments
 (0)