Skip to content

Commit

Permalink
Update cloudbuild config
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Jun 20, 2024
1 parent 548b352 commit f49867b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 35 deletions.
46 changes: 11 additions & 35 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
steps:
- name: gcr.io/cloud-builders/bazel:5.4.0
args: ['version']

- name: gcr.io/cloud-builders/bazel:5.4.0
args: ['build', '//cmd/...', '//images:etcd-manager', '//images:etcd-manager-slim', '//images:etcd-backup', '//images:etcd-dump']
# To build with GCS cache
#args: ['build', '--google_default_credentials', '--spawn_strategy=remote', '--genrule_strategy=remote', '--strategy=Javac=remote', '--strategy=Closure=remote', '--remote_http_cache=https://storage.googleapis.com/cache-bucket', '//cmd/...']

#- name: gcr.io/cloud-builders/bazel:5.4.0
# args: ['test', '//test/...', '--test_output=streamed', '--local_test_jobs=1']

- name: gcr.io/cloud-builders/bazel:5.4.0
args: ['run', '//images:push-etcd-manager']
- name: gcr.io/google.com/cloudsdktool/google-cloud-cli:slim
env:
- 'DOCKER_REGISTRY=${_DOCKER_REGISTRY}'
- 'DOCKER_IMAGE_PREFIX=${_DOCKER_IMAGE_PREFIX}'
- 'DOCKER_TAG=${_GIT_TAG}'
- name: gcr.io/cloud-builders/bazel:5.4.0
args: ['run', '//images:push-etcd-manager-slim']
env:
- 'DOCKER_REGISTRY=${_DOCKER_REGISTRY}'
- 'DOCKER_IMAGE_PREFIX=${_DOCKER_IMAGE_PREFIX}'
- 'DOCKER_TAG=${_GIT_TAG}'
- name: gcr.io/cloud-builders/bazel:5.4.0
args: ['run', '//images:push-etcd-dump']
env:
- 'DOCKER_REGISTRY=${_DOCKER_REGISTRY}'
- 'DOCKER_IMAGE_PREFIX=${_DOCKER_IMAGE_PREFIX}'
- 'DOCKER_TAG=${_GIT_TAG}'
- name: gcr.io/cloud-builders/bazel:5.4.0
args: ['run', '//images:push-etcd-backup']
env:
- 'DOCKER_REGISTRY=${_DOCKER_REGISTRY}'
- 'DOCKER_IMAGE_PREFIX=${_DOCKER_IMAGE_PREFIX}'
- 'DOCKER_TAG=${_GIT_TAG}'

- PULL_BASE_REF=$_PULL_BASE_REF
# We don't pass version; we want to use our own version tagging from git
#- VERSION=$_GIT_TAG
- DOCKER_REGISTRY=$_DOCKER_REGISTRY
- DOCKER_IMAGE_PREFIX=$_DOCKER_IMAGE_PREFIX
- ARTIFACT_LOCATION=$_ARTIFACT_LOCATION
- INSTALL_BAZELISK=y
entrypoint: dev/push-etcd-manager.sh
timeout: 1800s
substitutions:
_DOCKER_REGISTRY: 'us-central1-docker.pkg.dev'
_DOCKER_IMAGE_PREFIX: 'k8s-staging-images/etcd-manager/'
_GIT_TAG: 'dev'
_PULL_BASE_REF: 'dev'
options:
machineType: E2_HIGHCPU_8
substitution_option: ALLOW_LOOSE
59 changes: 59 additions & 0 deletions dev/push-etcd-manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Copyright 2020 The Kubernetes Authors.
#
# 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 -o errexit -o nounset -o pipefail
set -x;

# cd to the repo root
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

if [[ -z "${VERSION:-}" ]]; then
VERSION=$(git describe --always --match 'etcd-manager/*' | sed s@etcd-manager/@@g)
fi

if [[ -z "${DOCKER_REGISTRY:-}" ]]; then
DOCKER_REGISTRY=gcr.io
fi

if [[ -z "${DOCKER_IMAGE_PREFIX:-}" ]]; then
DOCKER_IMAGE_PREFIX=k8s-staging-etcdadm/
fi

if [[ -z "${ARTIFACT_LOCATION:-}" ]]; then
echo "must set ARTIFACT_LOCATION for binary artifacts"
exit 1
fi

# Make sure ARTIFACT_LOCATION ends in a slash
if [[ "${ARTIFACT_LOCATION}" != */ ]]; then
ARTIFACT_LOCATION="${ARTIFACT_LOCATION}/"
fi

if [[ -n "${INSTALL_BAZELISK:-}" ]]; then
DOWNLOAD_URL="https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64"
echo "Downloading bazelisk from $DOWNLOAD_URL"
curl -L --output "/tmp/bazelisk" "${DOWNLOAD_URL}"
chmod +x "/tmp/bazelisk"
# Install to /usr/local/bin
mv "/tmp/bazelisk" "/usr/local/bin/bazelisk"
# Use bazelisk for commands that invoke bazel
ln -sf "/usr/local/bin/bazelisk" "/usr/local/bin/bazel"
fi

# Build and upload etcd-manager images & binaries
DOCKER_REGISTRY=${DOCKER_REGISTRY} DOCKER_IMAGE_PREFIX=${DOCKER_IMAGE_PREFIX} DOCKER_TAG=${VERSION} make -C etcd-manager push
./etcd-manager/dev/build-assets.sh ${VERSION}
gsutil -h "Cache-Control:private, max-age=0, no-transform" -m cp -r -n etcd-manager/dist/ ${ARTIFACT_LOCATION}${VERSION}/etcd-manager/

0 comments on commit f49867b

Please sign in to comment.