Skip to content

Commit c5554de

Browse files
committed
Add release Makefile targets
Adds several Makefile targets to help create stable releases. The top-level one is "make releas" which should be called with a RELEASE_VERSION variable, e.g.: make release RELEASE_VERSION=0.3.0 Doing that changes the VERSION file, commits and tags that commit with the release version. Then, images using both Fedora and CentOS are built using that version as the tag instead of latest and pushed, finally the same images are built and pushed also using :latest.
1 parent 6ca6334 commit c5554de

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Makefile

+43-1
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,19 @@ $(GOPATH)/bin/golangci-lint:
108108
GOLANGCI_LINT_CACHE=/tmp/golangci-cache $(GOPATH)/bin/golangci-lint version
109109
GOLANGCI_LINT_CACHE=/tmp/golangci-cache $(GOPATH)/bin/golangci-lint linters
110110

111+
.PHONY: set-release-tag
112+
set-release-tag:
113+
$(eval IMAGE_TAG = $(VERSION))
114+
111115
.PHONY: image
112116
image: default-image centos-image fedora-image
113117

118+
.PHONY: release-image
119+
release-image: set-release-tag default-image centos-image fedora-image push push-fedora
120+
# This will ensure that we also push to the latest tag
121+
$(eval IMAGE_TAG = latest)
122+
$(MAKE) push
123+
114124
.PHONY: default-image
115125
default-image:
116126
$(CONTAINER_RUNTIME) build -f images/Dockerfile.centos -t $(IMAGE_REPO) .
@@ -124,9 +134,13 @@ fedora-image:
124134
$(CONTAINER_RUNTIME) build -f images/Dockerfile.fedora -t $(FEDORA_IMAGE_REPO) .
125135

126136
.PHONY: push
127-
push:
137+
push: default-image
128138
$(CONTAINER_RUNTIME) push $(IMAGE_REPO)
129139

140+
.PHONY: push-fedora
141+
push-fedora: fedora-image
142+
$(CONTAINER_RUNTIME) push $(FEDORA_IMAGE_REPO)
143+
130144
image.tar:
131145
$(MAKE) $(TEST_OS)-image && \
132146
$(CONTAINER_RUNTIME) save -o image.tar quay.io/security-profiles-operator/$(IMAGE_NAME)-$(TEST_OS):$(IMAGE_TAG); \
@@ -137,3 +151,31 @@ vagrant-up: image.tar ## Boot the vagrant based test VM
137151
# Retry in case provisioning failed because of some temporarily unavailable
138152
# remote resource (like the VM image)
139153
vagrant up || vagrant up || vagrant up
154+
155+
.PHONY: check-release-version
156+
check-release-version:
157+
ifndef RELEASE_VERSION
158+
$(error RELEASE_VERSION must be defined)
159+
endif
160+
161+
.PHONY: commit-release-version
162+
commit-release-version: check-release-version
163+
echo $(RELEASE_VERSION) > VERSION
164+
git add VERSION
165+
git commit -m "Release v$(RELEASE_VERSION)"
166+
$(eval VERSION = $(RELEASE_VERSION))
167+
168+
.PHONY: next-version
169+
next-version:
170+
# matches x.y.z where x,y,z are digits and then writes back x.y.99
171+
sed -i "s/\([0-9]\+\).\([0-9]\+\).[0-9]\+/\1.\2.99/" VERSION
172+
git add VERSION
173+
git commit -m "Prepare VERSION for the next release"
174+
175+
.PHONY: tag-release
176+
tag-release:
177+
git tag "v$(VERSION)"
178+
git push origin "v$(VERSION)"
179+
180+
.PHONY: release
181+
release: commit-release-version tag-release release-image next-version

0 commit comments

Comments
 (0)