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

Commit e3b2bcf

Browse files
authored
Merge pull request #200 from vincepri/release-goodies
🏃 Add release targets
2 parents 4a28a8a + 548318c commit e3b2bcf

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ jobs:
2323

2424
- name: Build and push container images
2525
uses: actions/gcloud/cli@master
26-
env:
27-
REGISTRY: gcr.io/k8s-staging-capi-kubeadm
28-
TAG: latest
2926
with:
3027
entrypoint: /bin/bash
3128
args: |
3229
-c "apt-get -y update && \
3330
apt-get -y --no-install-recommends install build-essential && \
34-
make docker-build-all docker-push-all"
31+
make release-staging-latest"

Makefile

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ $(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod
120120

121121
.PHONY: docker-build
122122
docker-build: ## Build the docker image for controller-manager
123-
docker build --pull --build-arg GOPROXY=$(GOPROXY) --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG)-$(ARCH):$(TAG)
124-
@echo "updating kustomize image patch file for manager resource"
125-
sed -i'' -e 's@image: .*@image: '"${CONTROLLER_IMG}-$(ARCH):$(TAG)"'@' ./config/default/manager_image_patch.yaml
123+
docker build --pull --build-arg ARCH=$(ARCH) . -t $(CONTROLLER_IMG)-$(ARCH):$(TAG)
124+
MANIFEST_IMG=$(CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) $(MAKE) set-manifest-image
126125

127126
.PHONY: docker-push
128127
docker-push: ## Push the docker image
@@ -150,6 +149,33 @@ docker-push-manifest: ## Push the fat manifest docker image.
150149
## Minimum docker version 18.06.0 is required for creating and pushing manifest images.
151150
docker manifest create --amend $(CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLLER_IMG)\-&:$(TAG)~g")
152151
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${TAG} ${CONTROLLER_IMG}-$${arch}:${TAG}; done
153-
docker manifest push --purge ${CONTROLLER_IMG}:${TAG}
154-
@echo "updating kustomize image patch file for manager resource"
155-
sed -i'' -e 's@image: .*@image: '"${CONTROLLER_IMG}:$(TAG)"'@' ./config/default/manager_image_patch.yaml
152+
MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) $(MAKE) set-manifest-image
153+
154+
.PHONY: set-manifest-image
155+
set-manifest-image:
156+
$(info Updating kustomize image patch file for manager resource)
157+
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/default/manager_image_patch.yaml
158+
159+
## --------------------------------------
160+
## Release
161+
## --------------------------------------
162+
163+
RELEASE_TAG := $(shell git describe --abbrev=0 2>/dev/null)
164+
165+
.PHONY: release
166+
release: ## Builds and push container images using the latest git tag for the commit.
167+
@if [ -z "${RELEASE_TAG}" ]; then echo "RELEASE_TAG is not set"; exit 1; fi
168+
# Push the release image to the staging bucket first.
169+
REGISTRY=gcr.io/k8s-staging-capi-kubeadm TAG=$(RELEASE_TAG) \
170+
$(MAKE) docker-build-all docker-push-all
171+
# Set the manifest image to the production bucket.
172+
REGISTRY=us.gcr.io/k8s-artifacts-prod/capi-kubeadm TAG=$(RELEASE_TAG) \
173+
set-manifest-image
174+
# Generate release artifacts.
175+
mkdir -p out/
176+
kustomize build config/default > out/bootstrap-components.yaml
177+
178+
.PHONY: release-staging-latest
179+
release-staging-latest: ## Builds and push container images to the staging bucket using "latest" tag.
180+
REGISTRY=gcr.io/k8s-staging-capi-kubeadm TAG=latest \
181+
$(MAKE) docker-build-all docker-push-all

0 commit comments

Comments
 (0)