99 lines
2.6 KiB
Makefile
99 lines
2.6 KiB
Makefile
NAME = netoik-cicd
|
|
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
|
|
BRANCH = $(shell [ -d ".git" ] && git branch --show-current)
|
|
|
|
TEMP_DIR = "${PWD}/.temp"
|
|
RPM_SOURCEDIR = $(shell rpm --eval "%{_sourcedir}")
|
|
|
|
SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
|
|
UNITDIR = $(shell rpm --eval "%{_unitdir}")
|
|
BINDIR = $(shell rpm --eval "%{_bindir}")
|
|
RUNDIR = $(shell rpm --eval "%{_rundir}")
|
|
TMPDIR = $(shell rpm --eval "%{_tmppath}")
|
|
|
|
.PHONY: build
|
|
build: bin/$(NAME)-deployer bin/$(NAME)-runner bin/$(NAME)-pipeline
|
|
|
|
bin/$(NAME)-deployer: src/deployer.sh
|
|
install -D --no-target-directory "$<" "$@"
|
|
|
|
bin/$(NAME)-runner: src/runner.sh
|
|
install -D --no-target-directory "$<" "$@"
|
|
|
|
bin/$(NAME)-pipeline: src/pipeline.sh
|
|
install -D --no-target-directory "$<" "$@"
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm --recursive --force ./bin
|
|
|
|
.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: conf/*.sample systemd/*.service bin/*
|
|
install -D \
|
|
--no-target-directory \
|
|
"conf/$(NAME).conf.sample" \
|
|
"$(DESTDIR)$(SYSCONFDIR)/$(NAME)/$(NAME).conf"
|
|
install -D \
|
|
--target-directory="$(DESTDIR)$(SYSCONFDIR)/$(NAME)" \
|
|
"conf/$(NAME).conf.sample"
|
|
install -D \
|
|
--no-target-directory \
|
|
conf/errors.conf.sample \
|
|
"$(DESTDIR)$(SYSCONFDIR)/$(NAME)/errors.conf"
|
|
install -D \
|
|
--target-directory="$(DESTDIR)$(SYSCONFDIR)/$(NAME)" \
|
|
conf/errors.conf.sample
|
|
install -D \
|
|
--no-target-directory \
|
|
"systemd/deployer.service" \
|
|
"$(DESTDIR)$(UNITDIR)/$(NAME)-deployer.service"
|
|
install -D \
|
|
--no-target-directory \
|
|
"systemd/runner.service" \
|
|
"$(DESTDIR)$(UNITDIR)/$(NAME)-runner.service"
|
|
install -D \
|
|
--target-directory="$(DESTDIR)$(BINDIR)" \
|
|
"bin/$(NAME)-deployer"
|
|
install -D \
|
|
--target-directory="$(DESTDIR)$(BINDIR)" \
|
|
"bin/$(NAME)-runner"
|
|
install -D \
|
|
--target-directory="$(DESTDIR)$(BINDIR)" \
|
|
"bin/$(NAME)-pipeline"
|
|
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/deployer"
|
|
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/runner"
|
|
install --directory "$(DESTDIR)$(RUNDIR)/$(NAME)/pipeline"
|
|
install --directory "$(DESTDIR)$(TMPDIR)/$(NAME)/repositories"
|
|
|
|
.PHONY: check_format
|
|
check_format:
|
|
shfmt --diff ./src
|
|
|
|
.PHONY: check_linting
|
|
check_linting:
|
|
shfmt --find ./src | xargs bash -o noexec
|
|
shfmt --find ./src | xargs shellcheck --external-sources
|
|
|
|
.PHONY: unit_test
|
|
unit_test:
|
|
bats ./tests
|