-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
103 lines (78 loc) · 3.26 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.PHONY: help clean tools dist test_pypi pypi pipx
.DEFAULT_GOAL := help
help: ## Display this help message.
@echo "Please use \`make <target>' where <target> is one of:"
@awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
clean: ## Remove stuff we don't need.
find . -name '__pycache__' -exec rm -rf {} +
rm -fr build/ dist/ src/*.egg-info
rm -f get_*.json get_index.txt
tools: ## Install the development tools.
python -m pip install -r dev-requirements.txt
test: ## Run the tests
coverage run -m pytest
dist: ## Build the distributions.
python -m build --sdist --wheel
python -m twine check dist/*
test_pypi: ## Upload the distributions to PyPI's testing server.
python -m twine upload --verbose --repository testpypi --password $$TWINE_TEST_PASSWORD dist/*
pypi: ## Upload the built distributions to PyPI.
python -m twine upload --verbose dist/*
pipx: ## Install locally as a command
pipx install --force -e .
.PHONY: cog_docs
cog_docs: _pip_install_e ## Run cog to get docs right
python -m cogapp -crP --verbosity=1 README.rst
.PHONY: test_release release check_release
test_release: clean check_release dist test_pypi ## Do all the steps for a test release
release: _check_credentials clean check_release dist pypi tag gh_release comment ## Do all the steps for a release
_check_credentials:
@if [[ -z "$$TWINE_PASSWORD" ]]; then \
echo 'Missing TWINE_PASSWORD: opvars'; \
exit 1; \
fi
@if [[ -z "$$GITHUB_TOKEN" ]]; then \
echo 'Missing GITHUB_TOKEN: opvars github'; \
exit 1; \
fi
check_release: _check_manifest _check_tree _check_readme _check_version ## Check that we are ready for a release
@echo "Release checks passed"
_pip_install_e:
python -m pip install -q -e .
_check_manifest:
python -m check_manifest
_check_tree:
@if [[ -n $$(git status --porcelain) ]]; then \
echo 'There are modified files! Did you forget to check them in?'; \
exit 1; \
fi
_check_readme: _pip_install_e
@if grep -q Unreleased README.rst; then \
echo 'I see Unreleased in README.rst! Did you forget to edit it?'; \
exit 1; \
fi
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
if grep -q $$VER README.rst; then \
echo 'Current version is in the README.rst'; \
else \
echo "No entry in README.rst for version $$VER!"; \
exit 1; \
fi
python -m cogapp -cP --check --verbosity=1 README.rst
_check_version: _pip_install_e
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
if [[ $$(git tags | grep -q -w $$VER && echo "x") == "x" ]]; then \
echo 'A git tag for this version exists! Did you forget to bump the version in src/watchgha/__init__.py?'; \
exit 1; \
fi
.PHONY: tag gh_release comment
tag: _pip_install_e ## Make a git tag with the version number
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
git tag -s -m "Version $$VER" $$VER
git push --all
gh_release: ## Publish a GitHub release
python -m scriv github-release --all
comment: ## Show the markdown for a "shipped" comment.
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
echo "Use this comment on issues and pull requests:" && \
echo " This is now released as part of [watchgha $$VER](https://pypi.org/project/watchgha/$$VER)."