@@ -20,7 +20,7 @@ SHELL:=/usr/bin/env bash
20
20
21
21
.DEFAULT_GOAL: =help
22
22
23
- GO_VERSION ?= 1.20.6
23
+ GO_VERSION ?= 1.20.7
24
24
GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION )
25
25
26
26
ARCH ?= $(shell go env GOARCH)
@@ -90,6 +90,32 @@ KUSTOMIZE_VER := v4.0.4
90
90
KUSTOMIZE_BIN := kustomize
91
91
KUSTOMIZE := $(TOOLS_BIN_DIR ) /$(KUSTOMIZE_BIN ) -$(KUSTOMIZE_VER )
92
92
93
+ # # --------------------------------------
94
+ # # Release
95
+ # # --------------------------------------
96
+
97
+ # #@ release:
98
+
99
+ # # latest git tag for the commit, e.g., v0.3.10
100
+ RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
101
+ ifneq (,$(findstring -,$(RELEASE_TAG ) ) )
102
+ PRE_RELEASE =true
103
+ endif
104
+ # the previous release tag, e.g., v0.3.9, excluding pre-release tags
105
+ PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | grep -B1 $(RELEASE_TAG ) | head -n 1 2>/dev/null)
106
+ # # set by Prow, ref name of the base branch, e.g., main
107
+ RELEASE_ALIAS_TAG := $(PULL_BASE_REF )
108
+ RELEASE_DIR := out
109
+ RELEASE_NOTES_DIR := _releasenotes
110
+
111
+ .PHONY : $(RELEASE_DIR )
112
+ $(RELEASE_DIR ) :
113
+ mkdir -p $(RELEASE_DIR ) /
114
+
115
+ .PHONY : $(RELEASE_NOTES_DIR )
116
+ $(RELEASE_NOTES_DIR ) :
117
+ mkdir -p $(RELEASE_NOTES_DIR ) /
118
+
93
119
94
120
all-bootstrap : manager-bootstrap
95
121
@@ -122,18 +148,17 @@ deploy-bootstrap: manifests-bootstrap
122
148
manifests-bootstrap : $(KUSTOMIZE ) $(CONTROLLER_GEN )
123
149
$(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=bootstrap/config/crd/bases output:rbac:dir=bootstrap/config/rbac
124
150
125
- release-bootstrap : manifests-bootstrap # # Release bootstrap
126
- mkdir -p out
151
+ release-bootstrap :$(RELEASE_DIR ) manifests-bootstrap # # Release bootstrap
127
152
cd bootstrap/config/manager && $(KUSTOMIZE ) edit set image controller=${BOOTSTRAP_IMG}
128
- $(KUSTOMIZE ) build bootstrap/config/default > out /bootstrap-components.yaml
153
+ $(KUSTOMIZE ) build bootstrap/config/default > $( RELEASE_DIR ) /bootstrap-components.yaml
129
154
130
155
# Generate code
131
156
generate-bootstrap : $(CONTROLLER_GEN )
132
157
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" $( shell pwd) /bootstrap/..."
133
158
134
159
# Build the docker image
135
160
docker-build-bootstrap : manager-bootstrap # # Build bootstrap
136
- DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH =$(ARCH ) --build-arg package=./bootstrap/main.go --build-arg ldflags=" $( LDFLAGS) " . -t ${BOOTSTRAP_IMG}
161
+ DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg TARGETARCH =$(ARCH ) --build-arg package=./bootstrap/main.go --build-arg ldflags=" $( LDFLAGS) " . -t ${BOOTSTRAP_IMG}
137
162
138
163
# Push the docker image
139
164
docker-push-bootstrap : # # Push bootstrap
@@ -170,21 +195,29 @@ deploy-controlplane: manifests-controlplane
170
195
manifests-controlplane : $(KUSTOMIZE ) $(CONTROLLER_GEN )
171
196
$(CONTROLLER_GEN ) rbac:roleName=manager-role webhook crd paths=" ./..." output:crd:artifacts:config=controlplane/config/crd/bases output:rbac:dir=controlplane/config/rbac
172
197
173
- release-controlplane : manifests-controlplane # # Release control-plane
174
- mkdir -p out
198
+ release-controlplane : $(RELEASE_DIR ) manifests-controlplane # # Release control-plane
175
199
cd controlplane/config/manager && $(KUSTOMIZE ) edit set image controller=${CONTROLPLANE_IMG}
176
- $(KUSTOMIZE ) build controlplane/config/default > out /control-plane-components.yaml
200
+ $(KUSTOMIZE ) build controlplane/config/default > $( RELEASE_DIR ) /control-plane-components.yaml
177
201
178
202
generate-controlplane : $(CONTROLLER_GEN )
179
203
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" $( shell pwd) /controlplane/..."
180
204
181
205
docker-build-controlplane : manager-controlplane # # Build control-plane
182
- DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH =$(ARCH ) --build-arg package=./controlplane/main.go --build-arg ldflags=" $( LDFLAGS) " . -t ${CONTROLPLANE_IMG}
206
+ DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg TARGETARCH =$(ARCH ) --build-arg package=./controlplane/main.go --build-arg ldflags=" $( LDFLAGS) " . -t ${CONTROLPLANE_IMG}
183
207
184
208
docker-push-controlplane : # # Push control-plane
185
209
docker push ${CONTROLPLANE_IMG}
186
210
187
211
release : release-bootstrap release-controlplane
212
+
213
+ .PHONY : release-notes
214
+ release-notes : $(RELEASE_NOTES_DIR ) $(RELEASE_NOTES )
215
+ if [ -n " ${PRE_RELEASE} " ]; then \
216
+ echo " :rotating_light: This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/kubernetes-sigs/cluster-api/issues/new)." > $(RELEASE_NOTES_DIR ) /$(RELEASE_TAG ) .md; \
217
+ else \
218
+ go run ./hack/tools/release/notes.go --from=$(PREVIOUS_TAG ) > $(RELEASE_NOTES_DIR ) /$(RELEASE_TAG ) .md; \
219
+ fi
220
+
188
221
# # --------------------------------------
189
222
# # Help
190
223
# # --------------------------------------
0 commit comments