diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..4daa7ec1bd4464514267745b13d5a7f99a922ae0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+GIT_DESC := $(shell git describe)
+VERSION := $(subst -,.,$(GIT_DESC))
+DIR := $(shell pwd)
+STASH_REF = $(shell git stash create)
+
+.PHONY: release-rpm dev-rpm clean
+
+release-rpm:
+	spectool --get-files check_dnf_automatic.spec
+	rpmbuild -bb check_dnf_automatic.spec --define "_topdir $(DIR)/rpmbuild" --define "_sourcedir $(DIR)"
+
+dev-rpm:
+	@sed -i 's/^Version:.*/Version:'" $(VERSION)"'/g' check_dnf_automatic.spec
+	@sed -i 's/^_version=.*/_version='"$(VERSION)"'/g' script/check_dnf_automatic
+	git archive --format=tar.gz -o "$(DIR)/check_dnf_automatic-$(VERSION).tar.gz" --prefix="check_dnf_automatic-$(VERSION)/" "$(STASH_REF)"
+	rpmbuild -bb check_dnf_automatic.spec --define "_topdir $(DIR)/rpmbuild" --define "_sourcedir $(DIR)"
+
+clean:
+	rm -f "$(DIR)/check_dnf_automatic-$(VERSION).tar.gz"
+	rm -fr "$(DIR)/rpmbuild"
diff --git a/README.md b/README.md
index 12de07906f756486f44555be8814f591b7d49bf3..9f2d8955df45793cf8af288c2e747174cef1ce7c 100644
--- a/README.md
+++ b/README.md
@@ -52,23 +52,18 @@ An Icinga plugin for monitoring the number of pending dnf-automatic security upd
 
 ### Development version
 
-Extract the package version from git. Set version in the spec file and the script. Create the source archive and build the RPM package.
+Extracts the package version from git. Sets version in the spec file and the script. Creates the source archive and builds the RPM package.
 
 ```bash
-_git_desc=$(git describe) && _version=${_git_desc//-/.} && echo "$_version"
-sed -i 's/^Version:.*/Version:'" ${_version}"'/g' check_dnf_automatic.spec
-sed -i 's/^_version=.*/_version='"${_version}"'/g' script/check_dnf_automatic
-git archive --format=tar.gz -o "$(pwd)/check_dnf_automatic-${_version}.tar.gz" --prefix="check_dnf_automatic-${_version}/" HEAD
-rpmbuild -bb check_dnf_automatic.spec --define "_topdir $(pwd)/rpmbuild" --define "_sourcedir $(pwd)"
+make dev-rpm
 ```
 
 ### Latest release
 
-Fetch the latest release and build the RPM package.
+Fetches the latest release and builds the RPM package.
 
 ```bash
-spectool --get-files check_dnf_automatic.spec
-rpmbuild -bb check_dnf_automatic.spec --define "_topdir $(pwd)/rpmbuild" --define "_sourcedir $(pwd)"
+make release-rpm
 ```
 
 ## Releasing a new version
diff --git a/ci/builds.gitlab-ci.yml b/ci/builds.gitlab-ci.yml
index da8ed695ae57ea105d1650f486daebce7d99fdc0..e6564e4bdc175da8f7b1d81d2b1094d5266f5b47 100644
--- a/ci/builds.gitlab-ci.yml
+++ b/ci/builds.gitlab-ci.yml
@@ -1,10 +1,9 @@
 .build:check_dnf_automatic:release:
   stage: build
   before_script:
-    - dnf install -y rpmdevtools rpm-build git
+    - dnf install -y rpmdevtools rpm-build git make
   script:
-    - spectool --get-files check_dnf_automatic.spec
-    - rpmbuild -bb check_dnf_automatic.spec --define "_topdir $(pwd)/rpmbuild" --define "_sourcedir $(pwd)"
+    - make release-rpm
     - mv rpmbuild/RPMS ./
   artifacts:
     paths:
@@ -13,14 +12,9 @@
 .build:check_dnf_automatic:development:
   stage: build
   before_script:
-    - dnf install -y rpmdevtools rpm-build git
+    - dnf install -y rpmdevtools rpm-build git make
   script:
-    - export _git_desc=$(git describe) && export _version=${_git_desc//-/.} && echo "$_version"
-    - sed -i 's/^Version:.*/Version:'" ${_version}"'/g' check_dnf_automatic.spec
-    - sed -i 's/^_version=.*/_version='"${_version}"'/g' script/check_dnf_automatic
-    - export _stash_ref=$(git stash create)
-    - git archive --format=tar.gz -o "$(pwd)/check_dnf_automatic-${_version}.tar.gz" --prefix="check_dnf_automatic-${_version}/" "$_stash_ref"
-    - rpmbuild -bb check_dnf_automatic.spec --define "_topdir $(pwd)/rpmbuild" --define "_sourcedir $(pwd)"
+    - make dev-rpm
     - mv rpmbuild/RPMS ./
   artifacts:
     paths: