Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit dac077d

Browse files
authored
Add kokoro release scripts and enable autorelease (#735)
Fix drop config Fix promote job, disable drop job Use gpg command enable debugging use stageRelease assemble then publish skip useLegacyGpg Fix signing for gax-bom skip artifacts
1 parent bd08bbd commit dac077d

File tree

12 files changed

+299
-0
lines changed

12 files changed

+299
-0
lines changed

.kokoro/release/common.cfg

Lines changed: 49 additions & 0 deletions
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: "gax-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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# Copyright 2019 Google Inc.
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_gradle_properties_file() {
32+
echo "
33+
signing.gnupg.executable=gpg
34+
signing.gnupg.homeDir=${GPG_HOMEDIR}
35+
signing.gnupg.keyName=${GPG_KEY_ID}
36+
signing.gnupg.passphrase=${GPG_PASSPHRASE}
37+
38+
ossrhUsername=${SONATYPE_USERNAME}
39+
ossrhPassword=${SONATYPE_PASSWORD}" > $1
40+
}

.kokoro/release/drop.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
env_vars: {
3+
key: "TRAMPOLINE_BUILD_FILE"
4+
value: "github/gax-java/.kokoro/release/drop.sh"
5+
}

.kokoro/release/drop.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Copyright 2019 Google Inc.
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+
echo "This dropping a staged repo does not appear supported by the gradle-nexus-staging-plugin"
19+
exit 1

.kokoro/release/promote.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
env_vars: {
3+
key: "TRAMPOLINE_BUILD_FILE"
4+
value: "github/gax-java/.kokoro/release/promote.sh"
5+
}

.kokoro/release/promote.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Copyright 2019 Google Inc.
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+
# STAGING_REPOSITORY_ID must be set
19+
#if [ -z "${STAGING_REPOSITORY_ID}" ]; then
20+
# echo "Missing STAGING_REPOSITORY_ID environment variable"
21+
# exit 1
22+
#fi
23+
24+
source $(dirname "$0")/common.sh
25+
pushd $(dirname "$0")/../../
26+
27+
setup_environment_secrets
28+
mkdir -p ${HOME}/.gradle
29+
create_gradle_properties_file "${HOME}/.gradle/gradle.properties"
30+
31+
./gradlew closeAndReleaseRepository
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
env_vars: {
3+
key: "STAGING_BUCKET"
4+
value: "docs-staging"
5+
}
6+
7+
env_vars: {
8+
key: "TRAMPOLINE_BUILD_FILE"
9+
value: "github/gax-java/.kokoro/release/publish_javadoc.sh"
10+
}
11+
12+
before_action {
13+
fetch_keystore {
14+
keystore_resource {
15+
keystore_config_id: 73713
16+
keyname: "docuploader_service_account"
17+
}
18+
}
19+
}

.kokoro/release/publish_javadoc.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# Copyright 2019 Google Inc.
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 [[ -z "${CREDENTIALS}" ]]; then
19+
CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account
20+
fi
21+
22+
if [[ -z "${STAGING_BUCKET}" ]]; then
23+
echo "Need to set STAGING_BUCKET environment variable"
24+
exit 1
25+
fi
26+
27+
# work from the git root directory
28+
pushd $(dirname "$0")/../../
29+
30+
# install docuploader package
31+
python3 -m pip install gcp-docuploader
32+
33+
NAME=gax
34+
VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3)
35+
36+
# build the docs
37+
./gradlew javadocCombined
38+
39+
pushd tmp_docs
40+
41+
# create metadata
42+
python3 -m docuploader create-metadata \
43+
--name ${NAME} \
44+
--version ${VERSION} \
45+
--language java
46+
47+
# upload docs
48+
python3 -m docuploader upload . \
49+
--credentials ${CREDENTIALS} \
50+
--staging-bucket ${STAGING_BUCKET}
51+
52+
popd

.kokoro/release/stage.cfg

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
env_vars: {
3+
key: "TRAMPOLINE_BUILD_FILE"
4+
value: "github/gax-java/.kokoro/release/stage.sh"
5+
}
6+
7+
# Fetch the token needed for reporting release status to GitHub
8+
before_action {
9+
fetch_keystore {
10+
keystore_resource {
11+
keystore_config_id: 73713
12+
keyname: "yoshi-automation-github-key"
13+
}
14+
}
15+
}
16+
17+
# Fetch magictoken to use with Magic Github Proxy
18+
before_action {
19+
fetch_keystore {
20+
keystore_resource {
21+
keystore_config_id: 73713
22+
keyname: "releasetool-magictoken"
23+
}
24+
}
25+
}
26+
27+
# Fetch api key to use with Magic Github Proxy
28+
before_action {
29+
fetch_keystore {
30+
keystore_resource {
31+
keystore_config_id: 73713
32+
keyname: "magic-github-proxy-api-key"
33+
}
34+
}
35+
}

.kokoro/release/stage.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Copyright 2019 Google Inc.
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+
python3 -m pip install gcp-releasetool
22+
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
23+
fi
24+
25+
source $(dirname "$0")/common.sh
26+
MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml
27+
pushd $(dirname "$0")/../../
28+
29+
setup_environment_secrets
30+
mkdir -p ${HOME}/.gradle
31+
create_gradle_properties_file "${HOME}/.gradle/gradle.properties"
32+
33+
./gradlew assemble publish
34+
35+
if [[ -n "${AUTORELEASE_PR}" ]]
36+
then
37+
./gradlew closeAndReleaseRepository
38+
fi

0 commit comments

Comments
 (0)