Skip to content

Commit

Permalink
Add release Makefile targets
Browse files Browse the repository at this point in the history
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 <jhrozek@redhat.com>
  • Loading branch information
jhrozek committed Apr 19, 2022
1 parent ae83268 commit ed8ddbc
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) .
Expand All @@ -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); \
Expand All @@ -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

0 comments on commit ed8ddbc

Please sign in to comment.