Skip to content

Commit

Permalink
chore: Using trampoline strategy for releases (#1541)
Browse files Browse the repository at this point in the history
* chore: Using trampoline strategy for releases

* chore: reinstating test command
  • Loading branch information
ddixit14 authored Jan 27, 2023
1 parent d58a9ce commit 1f7a8e3
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .kokoro/common.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "spring-cloud-gcp/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java17"
}

before_action {
fetch_keystore {
keystore_resource {
Expand Down
43 changes: 43 additions & 0 deletions .kokoro/populate-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# Copyright 2020 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eo pipefail

function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
function msg { println "$*" >&2 ;}
function println { printf '%s\n' "$(now) $*" ;}


# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
mkdir -p ${SECRET_LOCATION}
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
do
msg "Retrieving secret ${key}"
docker run --entrypoint=gcloud \
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
gcr.io/google.com/cloudsdktool/cloud-sdk \
secrets versions access latest \
--project cloud-devrel-kokoro-resources \
--secret ${key} > \
"${SECRET_LOCATION}/${key}"
if [[ $? == 0 ]]; then
msg "Secret written to ${SECRET_LOCATION}/${key}"
else
msg "Error retrieving secret ${key}"
fi
done
17 changes: 16 additions & 1 deletion .kokoro/stage.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Format: //devtools/kokoro/config/proto/build.proto

build_file: "spring-cloud-gcp/.kokoro/stage.sh"
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/spring-cloud-gcp/.kokoro/stage.sh"
}

action {
define_artifacts {
regex: "github/spring-cloud-gcp/target/nexus-staging/staging/*.properties"
strip_prefix: "github/spring-cloud-gcp"
}
}

env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
}
12 changes: 3 additions & 9 deletions .kokoro/stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ setup_environment_secrets
create_settings_xml_file $MAVEN_SETTINGS_FILE

# run unit tests
./mvnw verify --show-version --batch-mode

# change to release version
./mvnw versions:set --batch-mode -DremoveSnapshot -DprocessAllModules

# build and install the jars locally
./mvnw clean install --batch-mode -DskipTests=true
mvn verify --show-version --batch-mode

# stage release
./mvnw deploy \
mvn deploy \
--batch-mode \
--settings ${MAVEN_SETTINGS_FILE} \
-DskipTests=true \
Expand All @@ -51,7 +45,7 @@ create_settings_xml_file $MAVEN_SETTINGS_FILE
# promote release
if [[ -n "${AUTORELEASE_PR}" ]]
then
./mvnw nexus-staging:release \
mvn nexus-staging:release \
--batch-mode \
--settings ${MAVEN_SETTINGS_FILE} \
-Drelease=true \
Expand Down
26 changes: 26 additions & 0 deletions .kokoro/trampoline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
# Always run the cleanup script, regardless of the success of bouncing into
# the container.
function cleanup() {
chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
echo "cleanup";
}
trap cleanup EXIT

$(dirname $0)/populate-secrets.sh # Secret Manager secrets.
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"

0 comments on commit 1f7a8e3

Please sign in to comment.