@@ -29,6 +29,7 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT"
2929help :
3030 @python -c " $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
3131
32+
3233# CLEAN TARGETS
3334
3435.PHONY : clean-build
@@ -48,11 +49,8 @@ clean-pyc: ## remove Python file artifacts
4849
4950.PHONY : clean-docs
5051clean-docs : # # remove previously built docs
51- rm -rf docs/_build
52- rm -f docs/api/autobazaar.rst
53- rm -f docs/api/autobazaar.* .rst
54- rm -f docs/modules.rst
55- $(MAKE ) -C docs clean
52+ rm -f docs/api/* .rst
53+ -$(MAKE ) -C docs clean 2> /dev/null # this fails if sphinx is not yet installed
5654
5755.PHONY : clean-coverage
5856clean-coverage : # # remove coverage artifacts
@@ -99,12 +97,22 @@ fix-lint: ## fix lint issues using autoflake, autopep8, and isort
9997
10098# TEST TARGETS
10199
102- # .PHONY: test
103- # test: ## run tests quickly with the default Python
100+ # .PHONY: test-unit
101+ # test-unit : ## run tests quickly with the default Python
104102# python -m pytest --cov=autobazaar tests
105103
104+ .PHONY : test-readme
105+ test-readme : # # run the readme snippets
106+ python -m rundoc run --single-session bash -t bash README.md
107+
108+ .PHONY : test
109+ test : test-readme # # test everything that needs test dependencies
110+
111+ .PHONY : test-devel
112+ test-devel : lint docs # # test everything that needs development dependencies
113+
106114.PHONY : test-all
107- test-all : # # run tests on every Python version with tox
115+ test-all : # # test using tox
108116 tox -r
109117
110118.PHONY : coverage
@@ -119,7 +127,7 @@ coverage: ## check code coverage quickly with the default Python
119127
120128.PHONY : docs
121129docs : clean-docs # # generate Sphinx HTML documentation, including API docs
122- sphinx-apidoc --separate -T -o docs/api/ autobazaar
130+ sphinx-apidoc --module-first -- separate -T -o docs/api/ autobazaar
123131 $(MAKE ) -C docs html
124132
125133.PHONY : view-docs
@@ -139,12 +147,19 @@ dist: clean ## builds source and wheel package
139147 python setup.py bdist_wheel
140148 ls -l dist
141149
142- .PHONY : test-publish
143- test-publish : dist # # package and upload a release on TestPyPI
150+ .PHONY : publish-confirm
151+ publish-confirm :
152+ @echo " WARNING: This will irreversibly upload a new version to PyPI!"
153+ @echo -n " Please type 'confirm' to proceed: " \
154+ && read answer \
155+ && [ " $$ {answer}" = " confirm" ]
156+
157+ .PHONY : publish-test
158+ publish-test : dist publish-confirm # # package and upload a release on TestPyPI
144159 twine upload --repository-url https://test.pypi.org/legacy/ dist/*
145160
146161.PHONY : publish
147- publish : dist # # package and upload a release
162+ publish : dist publish-confirm # # package and upload a release
148163 twine upload dist/*
149164
150165.PHONY : bumpversion-release
@@ -154,11 +169,12 @@ bumpversion-release: ## Merge master to stable and bumpversion release
154169 bumpversion release
155170 git push --tags origin stable
156171
157- .PHONY : test- bumpversion-release
158- test- bumpversion-release : # # Merge master to stable and bumpversion release
172+ .PHONY : bumpversion-release-test
173+ bumpversion-release-test : # # Merge master to stable and bumpversion release
159174 git checkout stable || git checkout -b stable
160175 git merge --no-ff master -m" make release-tag: Merge branch 'master' into stable"
161- bumpversion release
176+ bumpversion release --no-tag
177+ @echo git push --tags origin stable
162178
163179.PHONY : bumpversion-patch
164180bumpversion-patch : # # Merge stable to master and bumpversion patch
@@ -167,11 +183,9 @@ bumpversion-patch: ## Merge stable to master and bumpversion patch
167183 bumpversion --no-tag patch
168184 git push
169185
170- .PHONY : test-bumpversion-patch
171- test-bumpversion-patch : # # Merge stable to master and bumpversion patch
172- git checkout master
173- git merge stable
174- bumpversion --no-tag patch
186+ .PHONY : bumpversion-candidate
187+ bumpversion-candidate : # # Bump the version to the next candidate
188+ bumpversion candidate --no-tag
175189
176190.PHONY : bumpversion-minor
177191bumpversion-minor : # # Bump the version the next minor skipping the release
@@ -181,21 +195,49 @@ bumpversion-minor: ## Bump the version the next minor skipping the release
181195bumpversion-major : # # Bump the version the next major skipping the release
182196 bumpversion --no-tag major
183197
198+ .PHONY : bumpversion-revert
199+ bumpversion-revert : # # Undo a previous bumpversion-release
200+ git checkout master
201+ git branch -D stable
202+
203+ CLEAN_DIR := $(shell git status --short | grep -v ??)
184204CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
185205CHANGELOG_LINES := $(shell git diff HEAD..origin/stable HISTORY.md 2>&1 | wc -l)
186206
187- .PHONY : check-release
188- check-release : # # Check if the release can be made
207+ .PHONY : check-clean
208+ check-clean : # # Check if the directory has uncommitted changes
209+ ifneq ($(CLEAN_DIR ) ,)
210+ $(error There are uncommitted changes)
211+ endif
212+
213+ .PHONY : check-master
214+ check-master : # # Check if we are in master branch
189215ifneq ($(CURRENT_BRANCH ) ,master)
190216 $(error Please make the release from master branch\n)
191217endif
218+
219+ .PHONY : check-history
220+ check-history : # # Check if HISTORY.md has been modified
192221ifeq ($(CHANGELOG_LINES ) ,0)
193222 $(error Please insert the release notes in HISTORY.md before releasing)
194223endif
195224
225+ .PHONY : check-release
226+ check-release : check-clean check-master check-history # # Check if the release can be made
227+ @echo " A new release can be made"
228+
196229.PHONY : release
197230release : check-release bumpversion-release publish bumpversion-patch
198231
232+ .PHONY : release-test
233+ release-test : check-release bumpversion-release-test publish-test bumpversion-revert
234+
235+ .PHONY : release-candidate
236+ release-candidate : check-master publish bumpversion-candidate
237+
238+ .PHONY : release-candidate-test
239+ release-candidate-test : check-clean check-master publish-test
240+
199241.PHONY : release-minor
200242release-minor : check-release bumpversion-minor release
201243
0 commit comments