| 1 |
# Copyright (C) 2019 Red Hat, Inc. All rights reserved. |
| 2 |
# |
| 3 |
# This library is free software; you can redistribute it and/or |
| 4 |
# modify it under the terms of the GNU Lesser General Public |
| 5 |
# License as published by the Free Software Foundation; either |
| 6 |
# version 2.1 of the License, or (at your option) any later version. |
| 7 |
# |
| 8 |
# This library is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
# Lesser General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU Lesser General Public |
| 14 |
# License along with this library; if not, write to the Free Software |
| 15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 16 |
# USA |
| 17 |
# |
| 18 |
PKGNAME = dasbus |
| 19 |
VERSION = $(shell awk '/Version:/ { print $$2 }' python-$(PKGNAME).spec) |
| 20 |
TAG = v$(VERSION) |
| 21 |
PYTHON ?= python3 |
| 22 |
COVERAGE ?= coverage3 |
| 23 |
|
| 24 |
# Container-related |
| 25 |
CI_NAME = $(PKGNAME)-ci |
| 26 |
CI_IMAGE ?= fedora |
| 27 |
CI_TAG ?= latest |
| 28 |
CI_CMD ?= make ci |
| 29 |
|
| 30 |
# Arguments used for setup.py call for creating archive |
| 31 |
BUILD_ARGS ?= sdist bdist_wheel |
| 32 |
|
| 33 |
# Arguments used by pylint for checking the code. |
| 34 |
CHECK_ARGS ?= |
| 35 |
|
| 36 |
.PHONY: clean |
| 37 |
clean: |
| 38 |
git clean -idx |
| 39 |
|
| 40 |
.PHONY: container-ci |
| 41 |
container-ci: |
| 42 |
podman build \ |
| 43 |
--file ".travis/Dockerfile.$(CI_IMAGE)" \ |
| 44 |
--build-arg TAG=$(CI_TAG) \ |
| 45 |
--tag $(CI_NAME) \ |
| 46 |
--pull-always |
| 47 |
|
| 48 |
podman run \ |
| 49 |
--volume .:/dasbus:Z \ |
| 50 |
--workdir /dasbus \ |
| 51 |
$(CI_NAME) $(CI_CMD) |
| 52 |
|
| 53 |
.PHONY: ci |
| 54 |
ci: |
| 55 |
@echo "*** Running CI with $(PYTHON) ***" |
| 56 |
$(PYTHON) --version |
| 57 |
$(MAKE) check |
| 58 |
$(MAKE) test |
| 59 |
$(MAKE) docs |
| 60 |
|
| 61 |
.PHONY: check |
| 62 |
check: |
| 63 |
@echo "*** Running pylint ***" |
| 64 |
$(PYTHON) -m pylint --version |
| 65 |
$(PYTHON) -m pylint $(CHECK_ARGS) dasbus/ tests/ |
| 66 |
|
| 67 |
.PHONY: test |
| 68 |
test: |
| 69 |
@echo "*** Running unittests with $(COVERAGE) ***" |
| 70 |
PYTHONPATH=. $(COVERAGE) run --rcfile=.coveragerc -m unittest discover -v -s tests/ |
| 71 |
$(COVERAGE) combine |
| 72 |
$(COVERAGE) report -m --include="dasbus/*" | tee coverage-report.log |
| 73 |
|
| 74 |
.PHONY: docs |
| 75 |
docs: |
| 76 |
$(MAKE) -C docs html text |
| 77 |
|
| 78 |
.PHONY: changelog |
| 79 |
changelog: |
| 80 |
@git log --no-merges --pretty="format:- %s (%ae)" $(TAG).. | sed -e 's/@.*)/)/' |
| 81 |
|
| 82 |
.PHONY: commit |
| 83 |
commit: |
| 84 |
@NEWSUBVER=$$((`echo $(VERSION) | cut -d . -f 2` + 1)) ; \ |
| 85 |
NEWVERSION=`echo $(VERSION).$$NEWSUBVER | cut -d . -f 1,3` ; \ |
| 86 |
DATELINE="* `LC_ALL=C.UTF-8 date "+%a %b %d %Y"` `git config user.name` <`git config user.email`> - $$NEWVERSION-1" ; \ |
| 87 |
cl=`grep -n %changelog python-${PKGNAME}.spec | cut -d : -f 1` ; \ |
| 88 |
tail --lines=+$$(($$cl + 1)) python-${PKGNAME}.spec > speclog ; \ |
| 89 |
(head -n $$cl python-${PKGNAME}.spec ; echo "$$DATELINE" ; make --quiet changelog 2>/dev/null ; echo ""; cat speclog) > python-${PKGNAME}.spec.new ; \ |
| 90 |
mv python-${PKGNAME}.spec.new python-${PKGNAME}.spec ; rm -f speclog ; \ |
| 91 |
sed -i "s/Version:\( *\)$(VERSION)/Version:\1$$NEWVERSION/" python-${PKGNAME}.spec ; \ |
| 92 |
sed -i "s/version=\"$(VERSION)\"/version=\"$$NEWVERSION\"/" setup.py ; \ |
| 93 |
git add python-${PKGNAME}.spec setup.py ; \ |
| 94 |
git commit -m "New release: $$NEWVERSION" |
| 95 |
|
| 96 |
.PHONY: tag |
| 97 |
tag: |
| 98 |
git tag -a -m "Tag as $(VERSION)" -f $(TAG) |
| 99 |
@echo "Tagged as $(TAG)" |
| 100 |
|
| 101 |
.PHONY: push |
| 102 |
push: |
| 103 |
@echo "Run the command 'git push --follow-tags' with '--dry-run' first." |
| 104 |
|
| 105 |
.PHONY: archive |
| 106 |
archive: |
| 107 |
$(PYTHON) setup.py ${BUILD_ARGS} |
| 108 |
@echo "The archive is in dist/$(PKGNAME)-$(VERSION).tar.gz" |
| 109 |
|
| 110 |
.PHONY: upload |
| 111 |
upload: |
| 112 |
$(PYTHON) -m twine upload dist/* |