-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
65 lines (53 loc) · 2.22 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
help:
@echo "install - install the package to the user's Python's site-packages"
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "lint - check style with flake8"
@echo "test - run tests"
@echo "deploy - package and upload a release"
@echo "release - tag a new release and update changelog"
@echo "build - create package"
@echo "publish - upload package to PyPI"
@echo "help - show this help and exit"
deploy: hashcathelper.pyz
@if [ -z $(SSH_TARGET) ] ; then echo "Environment variable SSH_TARGET is empty" ; return 0 ; else scp hashcathelper.pyz $(SSH_TARGET):.local/bin/hashcathelper ; fi
PYTHON ?= python3
hashcathelper.pyz: hashcathelper/
@$(eval TEMP_DIR := $(shell mktemp -d --suffix=.hashcathelper))
@$(eval GIT_HASH := $(shell git rev-parse --short HEAD))
$(PYTHON) -m pip install . --upgrade --target "${TEMP_DIR}"
@sed -i -E "s/'([0-9.]*)'/'\1-$(GIT_HASH)'/" ${TEMP_DIR}/hashcathelper/_meta.py
@$(PYTHON) -m zipapp "${TEMP_DIR}" -m hashcathelper.__main__:main -p '/usr/bin/env python3' --output hashcathelper.pyz
@rm -rf "${TEMP_DIR}"
clean:
@rm -rf build dist *.egg-info
@find . -type f -name '*.pyc' -delete
@find . -type d -name '__pycache__' | xargs rm -rf
@rm -rf .tox
@rm -f src/*.egg*
@rm -f hashcathelper.pyz
lint:
@flake8 hashcathelper
test:
@rm -rf .tox
@tox
docs:
@echo "Not yet implemented"
install:
python3 setup.py install --user
# \n in sed only works in GNU sed
release:
@read -p "Enter version string (Format: x.y.z): " version; \
echo "Version Bump: $$version"; \
date=$$(date +%F); \
sed -i "s/^## \[Unreleased\]/## [Unreleased]\n\n## [$$version] - $$date/" CHANGELOG.md && \
git add CHANGELOG.md && \
git commit -m "Version bump: $$version" && \
read -p "Committed. Do you want to tag and push the new version? [y/n] " ans && \
if [ $$ans = 'y' ] ; then git tag $$version && git push && git push origin tag $$version && echo "Tagged and pushed." ; else echo "Tag it and push it yourself then." ; fi
build:
python -m build
publish:
@file=$$(ls -1t dist/hashcathelper-*.tar.gz | head -n1); \
read -p "Ready to upload $$file? Type yes: " ans; \
if [ $$ans = 'yes' ] ; then twine upload $$file ; fi
.PHONY: build clean lint test docs deploy install help release publish