1- .PHONY : clean clean-test clean-pyc clean-build clean-docs docs help
21.DEFAULT_GOAL := help
32
43define BROWSER_PYSCRIPT
@@ -26,68 +25,101 @@ export PRINT_HELP_PYSCRIPT
2625
2726BROWSER := python -c "$$BROWSER_PYSCRIPT"
2827
28+ .PHONY : help
2929help :
3030 @python -c " $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
3131
3232
3333# CLEAN TARGETS
3434
35-
36- clean : clean-build clean-pyc clean-coverage clean-test clean-docs # # remove all build, test, coverage, docs and Python artifacts
37-
35+ .PHONY : clean-build
3836clean-build : # # remove build artifacts
3937 rm -fr build/
4038 rm -fr dist/
4139 rm -fr .eggs/
4240 find . -name ' *.egg-info' -exec rm -fr {} +
4341 find . -name ' *.egg' -exec rm -f {} +
4442
43+ .PHONY : clean-pyc
4544clean-pyc : # # remove Python file artifacts
4645 find . -name ' *.pyc' -exec rm -f {} +
4746 find . -name ' *.pyo' -exec rm -f {} +
4847 find . -name ' *~' -exec rm -f {} +
4948 find . -name ' __pycache__' -exec rm -fr {} +
5049
50+ .PHONY : clean-docs
5151clean-docs : # # remove previously built docs
5252 rm -f docs/api/* .rst
5353 $(MAKE ) -C docs clean
5454
55+ .PHONY : clean-coverage
5556clean-coverage : # # remove coverage artifacts
5657 rm -f .coverage
5758 rm -f .coverage.*
5859 rm -fr htmlcov/
5960
61+ .PHONY : clean-test
6062clean-test : # # remove test and coverage artifacts
6163 rm -fr .tox/
6264 rm -fr .pytest_cache
6365
66+ .PHONY : clean
67+ clean : clean-build clean-pyc clean-test clean-coverage clean-docs # # remove all build, test, coverage, docs and Python artifacts
6468
65- # LINT TARGETS
6669
70+ # INSTALL TARGETS
6771
72+ .PHONY : install
73+ install : clean-build clean-pyc # # install the package to the active Python's site-packages
74+ pip install .
75+
76+ .PHONY : install-test
77+ install-test : clean-build clean-pyc # # install the package and test dependencies
78+ pip install .[test]
79+
80+ .PHONY : install-develop
81+ install-develop : clean-build clean-pyc # # install the package in editable mode and dependencies for development
82+ pip install -e .[dev]
83+
84+
85+ # LINT TARGETS
86+
87+ .PHONY : lint
6888lint : # # check style with flake8 and isort
6989 flake8 cardea tests
7090 isort -c --recursive cardea tests
7191
92+
93+
94+ .PHONY : fix-lint
7295fixlint : # # fix lint issues using autoflake, autopep8, and isort
73- find cardea -name ' *.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables
96+ find cardea -name ' *.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports
7497 autopep8 --in-place --recursive --aggressive cardea
7598 isort --apply --atomic --recursive cardea
7699
77- find tests -name '*.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables
100+ find tests -name '*.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports
78101 autopep8 --in-place --recursive --aggressive tests
79102 isort --apply --atomic --recursive tests
80103
81104
82- # TEST TARGETS
83105
84106
107+
108+ # TEST TARGETS
109+
110+ .PHONY : test
85111test : # # run tests quickly with the default Python
86112 pytest
87113
114+ .PHONY : test-all
88115test-all : # # run tests on every Python version with tox
89116 tox
90117
118+
119+
120+
121+
122+ .PHONY : coverage
91123coverage : clean-coverage # # check code coverage quickly with the default Python
92124 coverage run --source cardea -m pytest
93125 coverage report -m
@@ -97,42 +129,90 @@ coverage: clean-coverage ## check code coverage quickly with the default Python
97129
98130# DOCS TARGETS
99131
100-
132+ .PHONY : docs
101133docs : clean-docs # # generate Sphinx HTML documentation, including API docs
102134 sphinx-apidoc --module-first --separate --no-toc --output-dir docs/api/ cardea
103135 $(MAKE ) -C docs html
104136 touch docs/_build/html/.nojekyll
105137
138+ .PHONY : viewdocs
106139viewdocs : docs # # view docs in browser
107140 $(BROWSER ) docs/_build/html/index.html
108141
142+ .PHONY : servedocs
109143servedocs : docs # # compile the docs watching for changes
110144 watchmedo shell-command -p ' *.rst' -c ' $(MAKE) -C docs html' -R -D .
111145
112146
113147# RELEASE TARGETS
114148
115-
116- release : dist # # package and upload a release
117- twine upload dist/*
118-
119- test-release : dist # # package and upload a release on TestPyPI
120- twine upload --repository-url https://test.pypi.org/legacy/ dist/*
121-
149+ .PHONY : dist
122150dist : clean # # builds source and wheel package
123151 python setup.py sdist
124152 python setup.py bdist_wheel
125153 ls -l dist
126154
155+ .PHONY : test-publish
156+ test-publish : dist # # package and upload a release on TestPyPI
157+ twine upload --repository-url https ://test.pypi.org/legacy/ dist/*
127158
128- # INSTALL TARGETS
129-
130-
131- install : clean-build clean-pyc # # install the package to the active Python's site-packages
132- pip install .
133-
134- install-test : clean-build clean-pyc # # install the package and test dependencies
135- pip install .[test]
159+ .PHONY : publish
160+ publish : dist # # package and upload a release
161+ twine upload dist/*
136162
137- install-develop : clean-build clean-pyc # # install the package in editable mode and dependencies for development
138- pip install -e .[dev]
163+ .PHONY : bumpversion-release
164+ bumpversion-release : # # Merge master to stable and bumpversion release
165+ git checkout stable
166+ git merge --no-ff master -m" make release-tag: Merge branch 'master' into stable"
167+ bumpversion release
168+ git push --tags origin stable
169+
170+ .PHONY : bumpversion-patch
171+ bumpversion-patch : # # Merge stable to master and bumpversion patch
172+ git checkout master
173+ git merge stable
174+ bumpversion --no-tag patch
175+ git push
176+
177+ .PHONY : bumpversion-candidate
178+ bumpversion-candidate : # # Bump the version to the next candidate
179+ bumpversion candidate --no-tag
180+
181+ .PHONY : bumpversion-minor
182+ bumpversion-minor : # # Bump the version the next minor skipping the release
183+ bumpversion --no-tag minor
184+
185+ .PHONY : bumpversion-major
186+ bumpversion-major : # # Bump the version the next major skipping the release
187+ bumpversion --no-tag major
188+
189+ CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
190+ CHANGELOG_LINES := $(shell git diff HEAD..stable HISTORY.md | wc -l)
191+
192+ .PHONY : check-master
193+ check-master : # # Check if we are in master branch
194+ ifneq ($(CURRENT_BRANCH ) ,master)
195+ $(error Please make the release from master branch\n)
196+ endif
197+
198+ .PHONY : check-history
199+ check-history : # # Check if HISTORY.md has been modified
200+ ifeq ($(CHANGELOG_LINES ) ,0)
201+ $(error Please insert the release notes in HISTORY.md before releasing)
202+ endif
203+
204+ .PHONY : check-release
205+ check-release : check-master check-history # # Check if the release can be made
206+ @echo " A new release can be made"
207+
208+ .PHONY : release
209+ release : check-release bumpversion-release publish bumpversion-patch
210+
211+ .PHONY : release-candidate
212+ release-candidate : check-master publish bumpversion-candidate
213+
214+ .PHONY : release-minor
215+ release-minor : check-release bumpversion-minor release
216+
217+ .PHONY : release-major
218+ release-major : check-release bumpversion-major release
0 commit comments