forked from macisamuele/language-formatters-pre-commit-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (52 loc) · 2.11 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
define check_env_variable
$(if $(strip $($1)),,$(error "$1" ENV VARIABLE IS REQUIRED!))
endef
ifndef EDITOR
ifneq ("$(wildcard /etc/alternatives/editor)","")
EDITOR := /etc/alternatives/editor
else
EDITOR := vi
endif
endif
venv: requirements-dev.txt setup.py setup.cfg
deactivate || true
rm -rf venv/ # Ensure that venv does not exist
tox -e venv
venv/bin/pre-commit install --install-hooks
.PHONY: development
development: venv
@true
.PHONY: test
test:
tox ${TOX_ARGS}
.PHONY: clean
clean:
rm -rf .tox/ .pytest_cache/ .coverage venv/
find -name *.pyc -delete
.PHONY: release
release: clean venv
$(eval $(call check_env_variable,NEXT_VERSION))
ifneq ($(shell git rev-parse --abbrev-ref HEAD),master)
$(error `make release` could be execute only on master branch)
endif
echo "Running tests for extra safety"
TOX_ARGS=--recreate $(MAKE) test
echo "Clean old artifacts"
rm -rf build/ dist/
sed -ri "s/^(version = ).*/\1${NEXT_VERSION}/" setup.cfg
sed -ri "s/^(=+)$$/\1\n\n${NEXT_VERSION} ($$(date "+%Y-%m-%d"))\n------------------\n- TODO: add notes/" CHANGELOG.md
${EDITOR} CHANGELOG.md
git add --patch setup.cfg CHANGELOG.md
git commit -m "Release version ${NEXT_VERSION}"
git tag "v${NEXT_VERSION}"
venv/bin/python setup.py sdist bdist_wheel
echo "Fill next release information"
venv/bin/twine upload -r pypi dist/*
git push origin master --tags
.PHONY: bump-download-releases
bump-download-releases: export KLINT_VERSION = $(shell curl --silent https://api.github.com/repos/pinterest/ktlint/releases/latest | jq -r .name)
bump-download-releases: export GOOGLE_JAVA_FORMATTER_VERSION = $(shell curl --silent https://api.github.com/repos/google/google-java-format/releases/latest | jq -r .name)
bump-download-releases:
sed -ri "s/(KTLINT_VERSION = )'.*'/\1'${KLINT_VERSION}'/" language_formatters_pre_commit_hooks/pretty_format_kotlin.py
sed -ri "s/(GOOGLE_JAVA_FORMATTER_VERSION = )'.*'/\1'${GOOGLE_JAVA_FORMATTER_VERSION}'/" language_formatters_pre_commit_hooks/pretty_format_java.py
git add --patch language_formatters_pre_commit_hooks/pretty_format_kotlin.py language_formatters_pre_commit_hooks/pretty_format_java.py