Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit dc4f078

Browse files
committed
✨ Add prow image building
Signed-off-by: Vince Prignano <[email protected]>
1 parent b7c1ea3 commit dc4f078

File tree

3 files changed

+58
-40
lines changed

3 files changed

+58
-40
lines changed

.github/workflows/main.yml

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

Makefile

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ docker-push-%:
153153
$(MAKE) ARCH=$* docker-push
154154

155155
.PHONY: docker-push-manifest
156-
docker-push-manifest: ## Push the fat manifest docker image
156+
docker-push-manifest: ## Push the fat manifest docker image.
157157
## Minimum docker version 18.06.0 is required for creating and pushing manifest images.
158158
docker manifest create --amend $(CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLLER_IMG)\-&:$(TAG)~g")
159159
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${TAG} ${CONTROLLER_IMG}-$${arch}:${TAG}; done
@@ -170,21 +170,52 @@ set-manifest-image:
170170
## --------------------------------------
171171

172172
RELEASE_TAG := $(shell git describe --abbrev=0 2>/dev/null)
173+
RELEASE_DIR := out
174+
175+
$(RELEASE_DIR):
176+
mkdir -p $(RELEASE_DIR)/
173177

174178
.PHONY: release
175-
release: ## Builds and push container images using the latest git tag for the commit
179+
release: clean-release ## Builds and push container images using the latest git tag for the commit.
176180
@if [ -z "${RELEASE_TAG}" ]; then echo "RELEASE_TAG is not set"; exit 1; fi
177181
# Push the release image to the staging bucket first.
178182
REGISTRY=$(STAGING_REGISTRY) TAG=$(RELEASE_TAG) \
179183
$(MAKE) docker-build-all docker-push-all
180184
# Set the manifest image to the production bucket.
181185
MANIFEST_IMG=$(PROD_REGISTRY)/$(IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG) \
182186
$(MAKE) set-manifest-image
183-
# Generate release artifacts.
184-
mkdir -p out/
185-
kustomize build config/default > out/bootstrap-components.yaml
187+
$(MAKE) release-manifests
188+
189+
.PHONY: release-manifests
190+
release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a release
191+
kustomize build config/default > $(RELEASE_DIR)/infrastructure-components.yaml
192+
193+
.PHONY: release-binary
194+
release-binary: $(RELEASE_DIR)
195+
docker run \
196+
--rm \
197+
-e CGO_ENABLED=0 \
198+
-e GOOS=$(GOOS) \
199+
-e GOARCH=$(GOARCH) \
200+
-v "$$(pwd):/workspace" \
201+
-w /workspace \
202+
golang:1.12.9 \
203+
go build -a -ldflags '-extldflags "-static"' \
204+
-o $(RELEASE_DIR)/$(notdir $(RELEASE_BINARY))-$(GOOS)-$(GOARCH) $(RELEASE_BINARY)
205+
206+
.PHONY: release-staging
207+
release-staging: ## Builds and push container images to the staging bucket.
208+
REGISTRY=$(STAGING_REGISTRY) $(MAKE) docker-build-all docker-push-all release-tag-latest
209+
210+
211+
.PHONY: release-tag-latest
212+
release-tag-latest: ## Adds the latest tag to the last build tag.
213+
## TODO(vincepri): Only do this when we're on master.
214+
gcloud container images add-tag $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):latest
186215

187-
.PHONY: release-staging-latest
188-
release-staging-latest: ## Builds and push container images to the staging bucket using "latest" tag
189-
REGISTRY=$(STAGING_REGISTRY) TAG=latest \
190-
$(MAKE) docker-build-all docker-push-all
216+
## --------------------------------------
217+
## Cleanup / Verification
218+
## --------------------------------------
219+
.PHONY: clean-release
220+
clean-release: ## Remove the release folder
221+
rm -rf $(RELEASE_DIR)

cloudbuild.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://cloud.google.com/cloud-build/docs/build-config
2+
timeout: 1200s
3+
options:
4+
substitution_option: ALLOW_LOOSE
5+
steps:
6+
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20190906-745fed4'
7+
entrypoint: make
8+
env:
9+
- DOCKER_CLI_EXPERIMENTAL=enabled
10+
- TAG=$_GIT_TAG
11+
- ADDITIONAL_TAG=$_PULL_BASE_REF
12+
args:
13+
- release-staging
14+
substitutions:
15+
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
16+
# can be used as a substitution
17+
_GIT_TAG: '12345'
18+
_PULL_BASE_REF: 'dev'

0 commit comments

Comments
 (0)