From ed8ddbc64b219190922776e65c3ecfbfefc17309 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 18 Apr 2022 17:04:10 +0200 Subject: [PATCH] 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. Signed-off-by: Jakub Hrozek --- Makefile | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 72fe0ca2..74ea2605 100644 --- a/Makefile +++ b/Makefile @@ -108,9 +108,19 @@ $(GOPATH)/bin/golangci-lint: GOLANGCI_LINT_CACHE=/tmp/golangci-cache $(GOPATH)/bin/golangci-lint version GOLANGCI_LINT_CACHE=/tmp/golangci-cache $(GOPATH)/bin/golangci-lint linters +.PHONY: set-release-tag +set-release-tag: + $(eval IMAGE_TAG = $(VERSION)) + .PHONY: image image: default-image centos-image fedora-image +.PHONY: release-image +release-image: set-release-tag default-image centos-image fedora-image push push-fedora + # This will ensure that we also push to the latest tag + $(eval IMAGE_TAG = latest) + $(MAKE) push + .PHONY: default-image default-image: $(CONTAINER_RUNTIME) build -f images/Dockerfile.centos -t $(IMAGE_REPO) . @@ -124,9 +134,13 @@ fedora-image: $(CONTAINER_RUNTIME) build -f images/Dockerfile.fedora -t $(FEDORA_IMAGE_REPO) . .PHONY: push -push: +push: default-image $(CONTAINER_RUNTIME) push $(IMAGE_REPO) +.PHONY: push-fedora +push-fedora: fedora-image + $(CONTAINER_RUNTIME) push $(FEDORA_IMAGE_REPO) + image.tar: $(MAKE) $(TEST_OS)-image && \ $(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 # Retry in case provisioning failed because of some temporarily unavailable # remote resource (like the VM image) vagrant up || vagrant up || vagrant up + +.PHONY: check-release-version +check-release-version: +ifndef RELEASE_VERSION + $(error RELEASE_VERSION must be defined) +endif + +.PHONY: commit-release-version +commit-release-version: check-release-version + echo $(RELEASE_VERSION) > VERSION + git add VERSION + git commit -m "Release v$(RELEASE_VERSION)" + $(eval VERSION = $(RELEASE_VERSION)) + +.PHONY: next-version +next-version: + # matches x.y.z where x,y,z are digits and then writes back x.y.99 + sed -i "s/\([0-9]\+\).\([0-9]\+\).[0-9]\+/\1.\2.99/" VERSION + git add VERSION + git commit -m "Prepare VERSION for the next release" + +.PHONY: tag-release +tag-release: + git tag "v$(VERSION)" + git push origin "v$(VERSION)" + +.PHONY: release +release: commit-release-version tag-release release-image next-version