forked from pycontribs/jira
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
140 lines (120 loc) · 4.99 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
all: info clean lint test docs dist upload release
.PHONY: all docs upload info req dist
PACKAGE_NAME := $(shell python setup.py --name)
PACKAGE_VERSION := $(shell python setup.py --version)
PYTHON_PATH := $(shell which python)
PLATFORM := $(shell uname -s | awk '{print tolower($$0)}')
ifeq ($(PLATFORM), darwin)
DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
else
DIR := $(shell dirname $(realpath $(MAKEFILE_LIST)))
endif
PYTHON_VERSION := $(shell python3 -c "import sys; print('py%s%s' % sys.version_info[0:2] + ('-conda' if 'conda' in sys.version or 'Continuum' in sys.version else ''))")
ifneq (,$(findstring conda, $(PYTHON_VERSION)))
#CONDA := $(shell conda info --envs | grep '*' | awk '{print $$1}')
CONDA := $(CONDA_DEFAULT_ENV)
endif
PREFIX :=
ifndef GIT_BRANCH
GIT_BRANCH=$(shell git branch | sed -n '/\* /s///p')
endif
info:
@echo "INFO: Building $(PACKAGE_NAME):$(PACKAGE_VERSION) on $(GIT_BRANCH) branch"
@echo "INFO: Python $(PYTHON_VERSION) from '$(PREFIX)' [$(CONDA)]"
clean:
@find . -name "*.pyc" -delete
@rm -rf .tox dist/* docs/build/*
package:
python setup.py sdist bdist_wheel build_sphinx
req:
@$(PREFIX)requires.io update-site -t ac3bbcca32ae03237a6aae2b02eb9411045489bb -r $(PACKAGE_NAME)
install: prepare
$(PREFIX)pip install .
# https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/install-the-atlassian-sdk-on-a-linux-or-mac-system#InstalltheAtlassianSDKonaLinuxorMacsystem-Homebrew
install-sdk:
ifeq ($(PLATFORM), darwin)
which atlas-run-standalone || brew tap atlassian/tap && brew install atlassian/tap/atlassian-plugin-sdk
else ifeq ($(PLATFORM), linux)
ifneq ($(USER), root)
@echo "Install of Atlassian SDK must be run as root (or with sudo)"
exit 1
endif
ifneq ($(wildcard /etc/debian_version),)
sh -c 'echo "deb https://packages.atlassian.com/atlassian-sdk-deb stable contrib" >/etc/apt/sources.list.d/atlassian_development.list'
curl -fsSL https://packages.atlassian.com/api/gpg/key/public | apt-key add -
apt-get install apt-transport-https
apt-get update
apt-get install atlassian-plugin-sdk
else ifneq ($(wildcard /etc/redhat-release),)
tmp_dir=$(mktemp -d)
curl https://marketplace.atlassian.com/download/plugins/atlassian-plugin-sdk-rpm/version/42380 -o ${tmp_dir}/atlassian-plugin-sdk.noarch.rpm
yum -y install ${tmp_dir}/atlassian-plugin-sdk.noarch.rpm
rm -rf ${tmp_dir}
else
@echo "Error: Cannot determine package manager to use to install atlassian-sdk. Please see:"
@echo "https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/install-the-atlassian-sdk-on-a-linux-or-mac-system"
exit 1
endif
endif
uninstall:
$(PREFIX)pip uninstall -y $(PACKAGE_NAME)
dist:
$(PREFIX)python setup.py sdist bdist_wheel
prepare:
@pyenv install -s 2.7.13
@pyenv install -s 3.4.5
@pyenv install -s 3.5.2
@pyenv install -s 3.6.0
@pyenv local 2.7.13 3.4.5 3.5.2 3.6.0
@echo "INFO: === Preparing to run for package:$(PACKAGE_NAME) platform:$(PLATFORM) py:$(PYTHON_VERSION) dir:$(DIR) ==="
#if [ -f ${HOME}/testspace/testspace ]; then ${HOME}/testspace/testspace config url ${TESTSPACE_TOKEN}@pycontribs.testspace.com/jira/tests ; fi;
testspace:
${HOME}/testspace/testspace publish build/results.xml
lint:
@echo "INFO: linting...."
$(PREFIX)tox -e lint
test: prepare lint
@echo "INFO: test"
$(PREFIX)python setup.py build test build_sphinx sdist bdist_wheel check --restructuredtext --strict
test-all:
@echo "INFO: test-all (extended/matrix tests)"
# tox should not run inside virtualenv because it does create and use multiple virtualenvs
pip install -q tox tox-pyenv
python -m tox
docs:
@echo "INFO: Building the docs"
$(PREFIX)pip install sphinx sphinx_rtd_theme
$(PREFIX)python setup.py build_sphinx
@mkdir -p docs/build/docset
@mkdir -p docs/build/html/docset
# cannot put doc2dash into requirements.txt file because is using pinned requirements
# @DOC2DASH_OPTS=$(shell [ -d "$HOME/Library/Application Support/doc2dash/DocSets" ] && echo '--add-to-global')
# doc2dash --force --name jira docs/build/html --destination docs/build/docset --icon docs/_static/python-32.png --online-redirect-url https://jira.readthedocs.io/en/stable/ $(DOC2DASH_OPTS)
# cd docs/build/docset && tar --exclude='.DS_Store' -czf ../html/docset/jira.tgz jira.docset
# # TODO: publish the docs
tag:
bumpversion --feature --no-input
git push origin master
git push --tags
release: req
ifeq ($(GIT_BRANCH),master)
tag
else
upload
web
@echo "INFO: Skipping release on this branch."
endif
upload:
rm -f dist/*
ifeq ($(GIT_BRANCH),develop)
@echo "INFO: Upload package to testpypi.python.org"
$(PREFIX)python setup.py check --restructuredtext --strict
$(PREFIX)python setup.py sdist bdist_wheel
$(PREFIX)twine upload --repository-url https://test.pypi.org/legacy/ dist/*
endif
ifeq ($(GIT_BRANCH),master)
@echo "INFO: Upload package to pypi.python.org"
$(PREFIX)python setup.py check --restructuredtext --strict
$(PREFIX)python setup.py sdist bdist_wheel
$(PREFIX)twine upload dist/*
endif