ci: improve workflows
Some checks failed
Continuous Integration / lint_n_build (push) Has been cancelled
Some checks failed
Continuous Integration / lint_n_build (push) Has been cancelled
This commit is contained in:
76
Makefile
76
Makefile
@@ -1,50 +1,86 @@
|
||||
NAME = netoik-db
|
||||
VERSION = $(shell git describe --abbrev=0)
|
||||
RELEASE = $(shell git rev-parse --short HEAD)
|
||||
REFERENCE = $(if $(GIT_REFERENCE),$(GIT_REFERENCE),$(shell git branch --show-current))
|
||||
BUILD_ARCH = noarch
|
||||
ARCH = noarch
|
||||
OWNER = samuel
|
||||
SUMMARY = "Netoïk Database Management System"
|
||||
LICENSE = "MIT"
|
||||
URL = "https://git.netoik.io/$(OWNER)/$(NAME)"
|
||||
SOURCE0 = "$(NAME)-$(VERSION)-$(RELEASE).tar.gz"
|
||||
|
||||
RPM_RPMDIR = $(shell rpm --eval '%{_rpmdir}')
|
||||
RPM_SBINDIR = $(shell rpm --eval '%{_sbindir}')
|
||||
RPM_SOURCEDIR = $(shell rpm --eval '%{_sourcedir}')
|
||||
RPM_SYSCONFDIR = $(shell rpm --eval '%{_sysconfdir}')
|
||||
RPM_UNITDIR = $(shell rpm --eval '%{_unitdir}')
|
||||
RPM_TARBALL_PATH = $(RPM_SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
|
||||
RPM_BUILD_PATH = $(RPM_RPMDIR)/$(BUILD_ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(BUILD_ARCH).rpm
|
||||
|
||||
RPM_TARBALL_PATH = $(RPM_SOURCEDIR)/$(SOURCE0)
|
||||
RPM_BUILD_PATH = $(RPM_RPMDIR)/$(ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(ARCH).rpm
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: name
|
||||
name:
|
||||
name: ## Show project name
|
||||
@echo "$(NAME)"
|
||||
|
||||
.PHONY: version
|
||||
version:
|
||||
version: ## Show current project version
|
||||
@echo "$(VERSION)"
|
||||
|
||||
.PHONY: release
|
||||
release:
|
||||
release: ## Show current project release
|
||||
@echo "$(RELEASE)"
|
||||
|
||||
.PHONY: build_arch
|
||||
build_arch:
|
||||
@echo "$(BUILD_ARCH)"
|
||||
.PHONY: arch
|
||||
arch: ## Show rpm arch target
|
||||
@echo "$(ARCH)"
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/postgres $(DESTDIR)$(RPM_UNITDIR)/postgresql.service.d
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/postgres files/postgres/postgresql.conf files/postgres/pg_hba.conf
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR)/postgresql.service.d files/systemd/postgres.conf
|
||||
.PHONY: owner
|
||||
owner: ## Show project owner name
|
||||
@echo "$(OWNER)"
|
||||
|
||||
.PHONY: summary
|
||||
summary: ## Show project summary
|
||||
@echo "$(SUMMARY)"
|
||||
|
||||
.PHONY: license
|
||||
license: ## Show project license
|
||||
@echo "$(LICENSE)"
|
||||
|
||||
.PHONY: url
|
||||
url: ## Show project homepage URL
|
||||
@echo "$(URL)"
|
||||
|
||||
.PHONY: source0
|
||||
source0: ## Show rpm source0 file name
|
||||
@echo "$(SOURCE0)"
|
||||
|
||||
$(RPM_TARBALL_PATH): *
|
||||
git archive --format=tar.gz \
|
||||
--output="$@" \
|
||||
--prefix="$(NAME)-$(VERSION)/" \
|
||||
--verbose \
|
||||
"$(REFERENCE)"
|
||||
HEAD
|
||||
|
||||
.PHONY: tarball
|
||||
tarball: $(RPM_TARBALL_PATH)
|
||||
tarball: $(RPM_TARBALL_PATH) ## Build rpm tarball
|
||||
|
||||
.PHONY: install
|
||||
install: ## Install files into rpm dest (requires env var DESTDIR)
|
||||
@if [ -z "$(DESTDIR)" ]; then \
|
||||
printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/postgres $(DESTDIR)$(RPM_UNITDIR)/postgresql.service.d
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/postgres files/postgres/postgresql.conf files/postgres/pg_hba.conf
|
||||
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR)/postgresql.service.d files/systemd/postgres.conf
|
||||
|
||||
.PHONY: upload
|
||||
upload:
|
||||
curl --fail-with-body --upload-file "$(RPM_BUILD_PATH)" --user "$(GIT_PACKAGES_USERNAME):$(GIT_PACKAGES_TOKEN)" https://git.netoik.io/api/packages/$(GIT_PACKAGES_USERNAME)/rpm/upload
|
||||
|
||||
upload: ## Upload rpm package to Gitea repository (requires env var PKG_TOKEN)
|
||||
@if [ -z "$(PKG_TOKEN)" ]; then \
|
||||
printf "[CRITICAL] Missing env var PKG_TOKEN\n[CRITICAL] This command is designed to be called by Gitea Actions only!\n" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
curl --fail-with-body --upload-file "$(RPM_BUILD_PATH)" --user "$(OWNER):$(PKG_TOKEN)" https://git.netoik.io/api/packages/$(OWNER)/rpm/upload
|
||||
|
||||
Reference in New Issue
Block a user