2
2
3
3
GIT_VERSION ?= $(shell git log -1 --format="% h")
4
4
RELEASE_TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
5
+ RELEASE_VERSION ?= $(shell cat VERSION)
6
+ IS_NEW_RELEASE ?= true
5
7
8
+ # are there uncommitted files?
6
9
ifneq ($(shell git status --porcelain) ,)
7
10
# next is used by GoReleaser as well when --spanshot is set
8
11
RELEASE_TAG := $(RELEASE_TAG ) -next
12
+ RELEASE_VERSION := $(RELEASE_VERSION ) -dirty
13
+ IS_NEW_RELEASE := false
9
14
endif
10
15
16
+ # do we consider this to be a valid new release? Or are we working going forward?
17
+ ifneq ($(shell git branch --show-current) ,master)
18
+ RELEASE_VERSION := $(RELEASE_VERSION ) -next
19
+ IS_NEW_RELEASE := false
20
+ else
21
+ ifeq ($(shell git diff HEAD~1 VERSION),)
22
+ RELEASE_VERSION := $(RELEASE_VERSION ) -next
23
+ IS_NEW_RELEASE := false
24
+ endif
25
+ endif
26
+
27
+ VERSION ?= $(RELEASE_VERSION )
28
+
11
29
# which arches can we support
12
30
ARCHES =arm64 amd64
13
31
@@ -37,7 +55,8 @@ E2E_FOCUS := "functional tests"
37
55
TOOLS_DIR := hack/tools
38
56
TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
39
57
BIN_DIR := bin
40
- TEST_E2E_DIR := test/e2e
58
+ TEST_DIR := test
59
+ TEST_E2E_DIR := $(TEST_DIR ) /e2e
41
60
42
61
# Binaries.
43
62
KUSTOMIZE := $(TOOLS_BIN_DIR ) /kustomize
@@ -112,16 +131,10 @@ CORE_VERSION ?= v0.3.5
112
131
CORE_API ?= https://api.github.com/repos/kubernetes-sigs/cluster-api/releases
113
132
CORE_URL ?= https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CORE_VERSION )
114
133
115
- # useful function
116
- word-dot = $(word $2,$(subst ., ,$1) )
117
-
118
- VERSION ?= $(RELEASE_TAG )
119
- VERSION_CONTRACT ?= v1alpha3
120
- VERSION_MAJOR ?= $(call word-dot,$(VERSION ) ,1)
121
- VERSION_MINOR ?= $(call word-dot,$(VERSION ) ,2)
134
+ # metadata file to be included in releases
135
+ METADATA_YAML ?= metadata.yaml
122
136
123
137
# actual releases
124
- RELEASE_VERSION ?= $(VERSION )
125
138
RELEASE_BASE := out/release/infrastructure-packet
126
139
RELEASE_DIR := $(RELEASE_BASE ) /$(RELEASE_VERSION )
127
140
FULL_RELEASE_DIR := $(realpath .) /$(RELEASE_DIR )
@@ -145,7 +158,6 @@ FULL_MANAGERLESS_MANIFEST := $(FULL_MANAGERLESS_DIR)/infrastructure-components.y
145
158
MANAGERLESS_CLUSTERCTLYAML := $(MANAGERLESS_BASE ) /clusterctl-$(MANAGERLESS_VERSION ) .yaml
146
159
147
160
# templates
148
- METADATA_TEMPLATE ?= templates/metadata-template.yaml
149
161
CLUSTERCTL_TEMPLATE ?= templates/clusterctl-template.yaml
150
162
CLUSTER_TEMPLATE ?= templates/cluster-template.yaml
151
163
@@ -197,10 +209,11 @@ test: generate fmt vet crds
197
209
go test ./... -coverprofile cover.out
198
210
199
211
# Run e2e tests
212
+ .PHONY : e2e
200
213
e2e :
201
214
# This is the name used inside the component.yaml for the container that runs the manager
202
215
# The image gets loaded inside kind from ./test/e2e/config/packet-dev.yaml
203
- $(E2E_FLAGS ) $(MAKE ) -C test/e2e run
216
+ $(E2E_FLAGS ) $(MAKE ) -C $( TEST_E2E_DIR ) run
204
217
205
218
# Build manager binary
206
219
manager : $(MANAGER )
@@ -222,11 +235,11 @@ uninstall: crds
222
235
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
223
236
deploy : crds
224
237
cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
225
- $(KUSTOMIZE ) build config/default | kubectl apply -f -
238
+ $(KUSTOMIZE ) build config/release | kubectl apply -f -
226
239
227
240
# Generate manifests e.g. CRD, RBAC etc.
228
241
crds : controller-gen
229
- $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
242
+ $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=config/resources/ crd/bases
230
243
231
244
# Run go fmt against code
232
245
fmt :
@@ -297,26 +310,27 @@ $(MANAGERLESS_DIR) $(MANAGERLESS_BASE):
297
310
298
311
.PHONY : semver release-clusterctl release-manifests release $(RELEASE_CLUSTERCTLYAML ) $(RELEASE_MANIFEST ) $(RELEASE_METADATA ) $(RELEASE_CLUSTER_TEMPLATE ) $(FULL_RELEASE_CLUSTERCTLYAML )
299
312
313
+ check-release :
314
+ @echo $(IS_NEW_RELEASE )
315
+
300
316
semver :
301
317
ifeq (,$(VERSION ) )
302
- $(error could not determine version to use from git tag , will not create artifacts)
318
+ $(error could not determine version to use from file , will not create artifacts)
303
319
endif
320
+ @echo "release version $(VERSION)"
304
321
305
322
306
323
manifest : kustomize semver release-manifests release-clusterctl release-cluster-template
307
324
308
- release :
309
- goreleaser release --rm-dist --snapshot --skip-publish --debug
310
-
311
- release/publish :
312
- goreleaser release --rm-dist
313
-
314
325
release-manifests : semver $(RELEASE_MANIFEST ) $(RELEASE_METADATA ) $(RELEASE_CLUSTER_TEMPLATE )
315
- $(RELEASE_MANIFEST ) : $(RELEASE_DIR ) # # Builds the manifests to publish with a release
316
- $(KUSTOMIZE ) build config/default > $@
326
+ release-version :
327
+ KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true $(KUSTOMIZE ) config set config/release image-tag $(VERSION )
328
+
329
+ $(RELEASE_MANIFEST ) : $(RELEASE_DIR ) release-version # # Builds the manifests to publish with a release
330
+ $(KUSTOMIZE ) build config/release > $@
317
331
318
- $(RELEASE_METADATA ) : semver $(RELEASE_DIR ) $( METADATA_TEMPLATE )
319
- cat $(METADATA_TEMPLATE ) | sed ' s/MAJOR/$(VERSION_MAJOR)/g ' | sed ' s/MINOR/$(VERSION_MINOR)/g ' | sed ' s/CONTRACT/$(VERSION_CONTRACT)/g ' > $@
332
+ $(RELEASE_METADATA ) : semver $(RELEASE_DIR )
333
+ cp $(METADATA_YAML ) $@
320
334
321
335
release-cluster-template : semver $(RELEASE_CLUSTER_TEMPLATE )
322
336
$(RELEASE_CLUSTER_TEMPLATE ) : $(RELEASE_DIR )
@@ -335,8 +349,8 @@ managerless-manifests: semver $(MANAGERLESS_MANIFEST) $(MANAGERLESS_METADATA)
335
349
$(MANAGERLESS_MANIFEST ) : $(MANAGERLESS_DIR )
336
350
$(KUSTOMIZE ) build config/managerless > $@
337
351
338
- $(MANAGERLESS_METADATA ) : semver $(MANAGERLESS_DIR ) $( METADATA_TEMPLATE )
339
- cat $(METADATA_TEMPLATE ) | sed ' s/MAJOR/$(VERSION_MAJOR)/g ' | sed ' s/MINOR/$(VERSION_MINOR)/g ' | sed ' s/CONTRACT/$(VERSION_CONTRACT)/g ' > $@
352
+ $(MANAGERLESS_METADATA ) : semver $(MANAGERLESS_DIR )
353
+ cp $(METADATA_YAML ) $@
340
354
341
355
managerless-cluster-template : semver $(MANAGERLESS_CLUSTER_TEMPLATE )
342
356
$(MANAGERLESS_CLUSTER_TEMPLATE ) : $(MANAGERLESS_DIR )
0 commit comments