Skip to content

Commit 528c0f7

Browse files
authored
chore: Switch release scripts to google standard
1 parent a0e4df5 commit 528c0f7

33 files changed

+830
-2736
lines changed

.cloudbuild/hello.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

.cloudbuild/hello.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/release-please.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
primaryBranch: main
2+
releaseType: ruby
3+
bumpMinorPreMajor: true
4+
packageName: functions_framework
5+
monorepoTags: true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Push docs to gh-pages"
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
push-gh-pages:
9+
env:
10+
ruby_version: "3.0"
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Install Ruby ${{ env.ruby_version }}
14+
uses: ruby/setup-ruby@v1
15+
with:
16+
ruby-version: ${{ env.ruby_version }}
17+
- name: Checkout repo
18+
uses: actions/checkout@v2
19+
- name: Install dependencies
20+
run: "gem install --no-document toys && bundle install"
21+
- name: Publish docs
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: |
25+
toys release publish-gh-pages --verbose < /dev/null

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ coverage/
55
doc/
66
pkg/
77
tmp/
8+
/node_modules/
9+
/package-lock.json

.kokoro/populate-secrets.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
# This file is called in the early stage of `trampoline_v2.sh` to
17+
# populate secrets needed for the CI builds.
18+
19+
set -eo pipefail
20+
21+
function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
22+
function msg { println "$*" >&2 ;}
23+
function println { printf '%s\n' "$(now) $*" ;}
24+
25+
# Populates requested secrets set in SECRET_MANAGER_KEYS
26+
27+
# In Kokoro CI builds, we use the service account attached to the
28+
# Kokoro VM. This means we need to setup auth on other CI systems.
29+
# For local run, we just use the gcloud command for retrieving the
30+
# secrets.
31+
32+
if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then
33+
GCLOUD_COMMANDS=(
34+
"docker"
35+
"run"
36+
"--entrypoint=gcloud"
37+
"--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}"
38+
"gcr.io/google.com/cloudsdktool/cloud-sdk"
39+
)
40+
if [[ "${TRAMPOLINE_CI:-}" == "kokoro" ]]; then
41+
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
42+
else
43+
echo "Authentication for this CI system is not implemented yet."
44+
exit 2
45+
# TODO: Determine appropriate SECRET_LOCATION and the GCLOUD_COMMANDS.
46+
fi
47+
else
48+
# For local run, use /dev/shm or temporary directory for
49+
# KOKORO_GFILE_DIR.
50+
if [[ -d "/dev/shm" ]]; then
51+
export KOKORO_GFILE_DIR=/dev/shm
52+
else
53+
export KOKORO_GFILE_DIR=$(mktemp -d -t ci-XXXXXXXX)
54+
fi
55+
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
56+
GCLOUD_COMMANDS=("gcloud")
57+
fi
58+
59+
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
60+
mkdir -p ${SECRET_LOCATION}
61+
62+
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
63+
do
64+
msg "Retrieving secret ${key}"
65+
"${GCLOUD_COMMANDS[@]}" \
66+
secrets versions access latest \
67+
--project cloud-devrel-kokoro-resources \
68+
--secret $key > \
69+
"$SECRET_LOCATION/$key"
70+
if [[ $? == 0 ]]; then
71+
msg "Secret written to ${SECRET_LOCATION}/${key}"
72+
else
73+
msg "Error retrieving secret ${key}"
74+
exit 2
75+
fi
76+
done

.kokoro/release.cfg

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Download resources for system tests (service account key, etc.)
11+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
12+
13+
# Download trampoline resources.
14+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
15+
16+
# Use the trampoline script to run in docker.
17+
build_file: "functions-framework-ruby/.kokoro/trampoline_v2.sh"
18+
19+
# Configure the docker image for kokoro-trampoline.
20+
env_vars: {
21+
key: "TRAMPOLINE_IMAGE"
22+
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/release"
23+
}
24+
25+
env_vars: {
26+
key: "TRAMPOLINE_BUILD_FILE"
27+
value: ".kokoro/release.sh"
28+
}
29+
30+
env_vars: {
31+
key: "SECRET_MANAGER_KEYS"
32+
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,docuploader_service_account"
33+
}

.kokoro/release.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
# Install gems in the user directory because the default install directory
6+
# is in a read-only location.
7+
export GEM_HOME=$HOME/.gem
8+
export PATH=$GEM_HOME/bin:$PATH
9+
10+
python3 -m pip install git+https://github.com/googleapis/releasetool
11+
python3 -m pip install gcp-docuploader
12+
gem install --no-document toys
13+
14+
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
15+
toys release perform -v --enable-docs --enable-rad < /dev/null

0 commit comments

Comments
 (0)