netoik-cicd/Makefile

46 lines
1.5 KiB
Makefile

NAME = netoik-cicd
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
BRANCH = $(shell [ -d ".git" ] && git branch --show-current)
RPM_SOURCEDIR = $(shell rpm --eval "%{_sourcedir}")
SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
UNITDIR = $(shell rpm --eval "%{_unitdir}")
BINDIR = $(shell rpm --eval "%{_bindir}")
TMPDIR = $(shell rpm --eval "%{_tmppath}")
.PHONY: build
build: bin/$(NAME)-deployer bin/$(NAME)-newtag
bin/$(NAME)-deployer: src/deployer.sh
mkdir --parents bin
cp "$<" "$@"
bin/$(NAME)-newtag: src/newtag.sh
mkdir --parents bin
cp "$<" "$@"
.PHONY: name
name:
@echo "$(NAME)"
.PHONY: version
version:
@echo "$(VERSION)"
$(RPM_SOURCEDIR)/$(NAME)-%.tar.gz: *
git archive --format=tar.gz --output="$@" --prefix="$(NAME)-$(VERSION)/" --worktree-attributes --verbose "$(BRANCH)"
.PHONY: tarball
tarball: $(RPM_SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
.PHONY: install
install:
install -D --no-target-directory deployer.conf.sample "$(DESTDIR)$(SYSCONFDIR)/$(NAME)/deployer.conf"
install -D --target-directory="$(DESTDIR)$(SYSCONFDIR)/$(NAME)" deployer.conf.sample
install -D --target-directory="$(DESTDIR)$(SYSCONFDIR)/profile.d" profile/$(NAME)-git.sh
install -D --target-directory="$(DESTDIR)$(UNITDIR)" systemd/$(NAME)-deployer.service
install -D --target-directory="$(DESTDIR)$(BINDIR)" bin/$(NAME)-*
install --directory "$(DESTDIR)$(TMPDIR)/$(NAME)/deployer/request"
install --directory "$(DESTDIR)$(TMPDIR)/$(NAME)/deployer/response"