-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
119 lines (93 loc) · 3.1 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
PYTHON := python3
ACTIONLINT_VERSION := v1.6.9
SHELLCHECK_VERSION := v0.8.0
PACKAGE := pytablewriter
BIN_DIR := $(shell pwd)/bin
DOCS_DIR := docs
BUILD_WORK_DIR := _work
PKG_BUILD_DIR := $(BUILD_WORK_DIR)/$(PACKAGE)
CACHE_VERSION := 0
PKG_CACHE_ROOT_DIR := $(HOME)/.cache/downloaded
PKG_CACHE_DIR := $(PKG_CACHE_ROOT_DIR)/$(CACHE_VERSION)
SHELLCHECK_CACHE_DIR := $(PKG_CACHE_DIR)/shellcheck-$(SHELLCHECK_VERSION)
AUTHOR := Tsuyoshi Hombashi
FIRST_RELEASE_YEAR := 2016
LAST_UPDATE_YEAR := $(shell git log -1 --format=%cd --date=format:%Y)
BIN_CHANGELOG_FROM_RELEASE := $(BIN_DIR)/changelog-from-release
$(BIN_CHANGELOG_FROM_RELEASE):
mkdir -p $(BIN_DIR)
GOBIN=$(BIN_DIR) go install github.com/rhysd/changelog-from-release/v3@latest
$(SHELLCHECK_CACHE_DIR):
@echo "installing shellcheck $(SHELLCHECK_VERSION)"
@mkdir -p $(SHELLCHECK_CACHE_DIR)
@curl -sSLf https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz | tar -xJv -C $(SHELLCHECK_CACHE_DIR) --strip-components 1 --no-anchored shellcheck
@$(SUDO) mv $(SHELLCHECK_CACHE_DIR)/shellcheck /usr/local/bin/shellcheck
shellcheck --version
.PHONY: actionlint
actionlint: setup-actionlint
@actionlint -ignore=SC204 -ignore=SC2086 -ignore=SC2129
.PHONY: build-remote
build-remote: clean
@mkdir -p $(BUILD_WORK_DIR)
@cd $(BUILD_WORK_DIR) && \
git clone https://github.com/thombashi/$(PACKAGE).git --depth 1 && \
cd $(PACKAGE) && \
$(PYTHON) -m tox -e build
ls -lh $(PKG_BUILD_DIR)/dist/*
.PHONY: build
build: clean
@$(PYTHON) -m tox -e build
ls -lh dist/*
.PHONY: changelog
changelog: $(BIN_CHANGELOG_FROM_RELEASE)
$(BIN_CHANGELOG_FROM_RELEASE) > CHANGELOG.md
cp -a CHANGELOG.md docs/pages/CHANGELOG.md
.PHONY: check
check:
$(PYTHON) -m tox -e lint
$(PYTHON) -m tox -e lint-examples
.PHONY: clean
clean:
@rm -rf $(BUILD_WORK_DIR)
@$(PYTHON) -m tox -e clean
.PHONY: docs
docs:
@$(PYTHON) -m tox -e docs
.PHONY: idocs
idocs:
@$(PYTHON) -m pip install --upgrade -q --disable-pip-version-check -e .
@$(MAKE) docs
.PHONY: fmt
fmt:
@$(PYTHON) -m tox -e fmt
.PHONY: readme
readme:
@$(PYTHON) -m tox -e readme
.PHONY: release
release:
$(PYTHON) -m tox -e release
$(MAKE) clean
.PHONY: setup-actionlint
setup-actionlint:
@go install github.com/rhysd/actionlint/cmd/actionlint@${ACTIONLINT_VERSION}
actionlint --version
.PHONY: setup-ci
setup-ci:
$(PYTHON) -m pip install -q --disable-pip-version-check --upgrade pip
$(PYTHON) -m pip install -q --disable-pip-version-check --upgrade tox
.PHONY: setup-shellcheck
setup-shellcheck: $(SHELLCHECK_CACHE_DIR)
.PHONY: setup-dev
setup-dev: setup-actionlint setup-ci setup-shellcheck
$(PYTHON) -m pip install --upgrade -q --disable-pip-version-check -e .[test]
$(PYTHON) -m pip check
.PHONY: test
test:
$(PYTHON) -m tox
.PHONY: test-py
test-py:
$(PYTHON) -m tox -e py
.PHONY: update-copyright
update-copyright:
sed -i "s/f\"Copyright .*/f\"Copyright $(FIRST_RELEASE_YEAR)-$(LAST_UPDATE_YEAR), {__author__}\"/" $(PACKAGE)/__version__.py
sed -i "s/^Copyright (c) .* $(AUTHOR)/Copyright (c) $(FIRST_RELEASE_YEAR)-$(LAST_UPDATE_YEAR) $(AUTHOR)/" LICENSE