-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
58 lines (48 loc) · 1.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Helper functions.
define commit
$(shell git rev-parse HEAD)
endef
define tag
$(or $(strip $(shell git tag --sort=taggerdate | tail -1)),undefined)
endef
COMMIT := $(call commit)
TAG := $(call tag)
NEW_VERSION = $(if $(filter-out $(TAG),$(call tag)),1,)
init:
python -m pip install -q --upgrade pip
python -m pip install -q --upgrade poetry
poetry install
git config core.hooksPath .hooks
test:
poetry run python -m unittest discover
coverage:
poetry run python -m coverage run -m unittest discover
poetry run python -m coverage xml -i
# If version bump is needed, this bumps version, commits the change, and tags it.
version:
@poetry run semantic-release version
# Generates changelog if necessary.
changelog:
@if [ "$(NEW_VERSION)" = "1" ]; \
then \
echo "Generating changelog." \
&& echo "## " $(call tag) > tmp.md \
&& poetry run semantic-release changelog >> tmp.md \
&& cat CHANGELOG.md >> tmp.md \
&& mv tmp.md CHANGELOG.md; \
else \
echo "No changelog needed. Same version."; \
fi
deps:
poetry export --dev -f requirements.txt > requirements.txt
# Builds a new release.
publish: version changelog deps
@if [ "$(NEW_VERSION)" = "1" ]; \
then \
echo "Creating a release" \
&& git commit -a --amend --no-edit \
&& poetry build \
&& poetry publish -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} \
&& ./bin/hub push origin \
&& ./bin/hub release create -m "$(call tag)" $(strip $(call tag)); \
else echo "Skipping release, no new version to publish"; fi