Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ REGISTRY ?= us.gcr.io/k8s-artifacts-prod/external-dns
IMAGE ?= $(REGISTRY)/$(BINARY)
VERSION ?= $(shell git describe --tags --always --dirty --match "v*")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
GIT_REVISION ?= $(shell git rev-parse HEAD)
BUILD_FLAGS ?= -v
LDFLAGS ?= -X sigs.k8s.io/external-dns/pkg/apis/externaldns.Version=$(VERSION) -w -s
LDFLAGS += -X sigs.k8s.io/external-dns/pkg/apis/externaldns.GitCommit=$(GIT_COMMIT)
Expand All @@ -108,7 +109,7 @@ build.push/multiarch: ko
VERSION=${VERSION} \
ko build --tags ${VERSION} --bare --sbom ${IMG_SBOM} \
--image-label org.opencontainers.image.source="https://github.com/kubernetes-sigs/external-dns" \
--image-label org.opencontainers.image.revision=$(shell git rev-parse HEAD) \
--image-label org.opencontainers.image.revision=$(GIT_REVISION) \
--platform=${IMG_PLATFORM} --push=${IMG_PUSH} .

build.image/multiarch:
Expand Down
32 changes: 30 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,44 @@ timeout: 5000s
options:
substitution_option: ALLOW_LOOSE
machineType: 'N1_HIGHCPU_8'
volumes:
- name: go-modules
path: /go/pkg/mod
steps:
# Pre-warm the Go module cache so test and build steps don't compete for downloads.
- name: 'docker.io/library/golang:1.26-bookworm'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  ┌──────────┬────────────┬──────────────────────┬───────────────────────────────────────────────────────────────────┐
  │   Step   │ entrypoint │         args         │                              Result                               │
  ├──────────┼────────────┼──────────────────────┼───────────────────────────────────────────────────────────────────┤
  │ pre-warm │ go         │ mod download         │ go mod download ✓                                                 │
  ├──────────┼────────────┼──────────────────────┼───────────────────────────────────────────────────────────────────┤
  │ test     │ make       │ test                 │ make test → go test -race ./... ✓                                 │
  ├──────────┼────────────┼──────────────────────┼───────────────────────────────────────────────────────────────────┤
  │ build    │ make       │ build.push/multiarch │ make build.push/multiarch with VERSION, GIT_REVISION, IMAGE env ✓ │
  └──────────┴────────────┴──────────────────────┴───────────────────────────────────────────────────────────────────┘

entrypoint: go
volumes:
- name: go-modules
path: /go/pkg/mod
args:
- mod
- download

# Run tests in a separate step so the build step starts with a clean memory slate.
- name: 'docker.io/library/golang:1.26-bookworm'
entrypoint: make
volumes:
- name: go-modules
path: /go/pkg/mod
args:
- test

# Build and push multi-arch images using the pre-warmed cache.
- name: 'docker.io/library/golang:1.26-bookworm'
entrypoint: make
volumes:
- name: go-modules
path: /go/pkg/mod
env:
- VERSION=$_GIT_TAG
- PULL_BASE_REF=$_PULL_BASE_REF
- GIT_REVISION=$_GIT_COMMIT
- IMAGE=gcr.io/k8s-staging-external-dns/external-dns
args:
- release.staging
- build.push/multiarch
substitutions:
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
# can be used as a substitution
_GIT_TAG: "12345"
_GIT_COMMIT: ""
_PULL_BASE_REF: 'master'
Loading