forked from artsy/hokusai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
120 lines (103 loc) · 3.39 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
.PHONY: dependencies test test-docker build build-linux-docker image publish-head publish-latest publish-version publish-pip publish-dockerhub publish-head-dockerhub publish-github clean
AWS ?= $(shell which aws)
DOCKER_RUN ?= $(shell which docker) run --rm
GIT_PUSH ?= $(shell which git) push
GIT_TAG ?= $(shell which git) tag --sign
DIST_DIR ?= dist/
PROJECT = github.com/artsy/hokusai
VERSION ?= $(shell cat hokusai/VERSION)
MINOR_VERSION ?= $(shell cat hokusai/VERSION | awk -F"." '{ print $$1"."$$2 }')
dependencies:
pip install pipenv --quiet --ignore-installed
pipenv install --dev
test:
pipenv run unit-tests
integration:
pipenv run integration-tests
test-docker:
$(DOCKER_RUN) \
--volume "$(PWD)":"/src/$(PROJECT):ro" \
--workdir "/src/$(PROJECT)" \
python:2 make dependencies test
build: BINARY_SUFFIX ?= -$(VERSION)-$(shell uname -s)-$(shell uname -m)
build:
pipenv run pyinstaller \
--distpath=$(DIST_DIR) \
--workpath=/tmp/build/ \
hokusai.spec
mkdir -p $(DIST_DIR)hokusai$(BINARY_SUFFIX)
cp $(DIST_DIR)hokusai $(DIST_DIR)hokusai$(BINARY_SUFFIX)/hokusai
tar cfvz $(DIST_DIR)hokusai$(BINARY_SUFFIX).tar.gz -C $(DIST_DIR)hokusai$(BINARY_SUFFIX) .
rm -rf $(DIST_DIR)hokusai$(BINARY_SUFFIX)
mv $(DIST_DIR)hokusai $(DIST_DIR)hokusai$(BINARY_SUFFIX)
build-linux-docker:
$(DOCKER_RUN) \
--env VERSION \
--env DIST_DIR=/dist/ \
--volume "$(PWD)"/dist:/dist \
--volume "$(PWD)":"/src/$(PROJECT):ro" \
--workdir "/src/$(PROJECT)" \
python:2 make dependencies build
image:
echo $(VERSION)
docker build . \
--tag hokusai
publish-head:
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-head-*" \
dist/ s3://artsy-provisioning-public/hokusai/
publish-latest:
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-latest-*" \
dist/ s3://artsy-provisioning-public/hokusai/
publish-version:
if [ "$(shell curl --silent https://s3.amazonaws.com/artsy-provisioning-public/hokusai/hokusai-$(VERSION)-linux-amd64 --output /dev/null --write-out %{http_code})" -eq 403 ]; then \
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-$(VERSION)-*" \
dist/ s3://artsy-provisioning-public/hokusai/; \
else \
echo "Version $(VERSION) already published"; \
exit 1; \
fi
publish-pip:
pipenv run python setup.py sdist bdist_wheel
pipenv run twine upload dist/*
publish-dockerhub:
if [ "$(shell curl --silent https://index.docker.io/v1/repositories/artsy/hokusai/tags/$(VERSION) --output /dev/null --write-out %{http_code})" -eq 404 ]; then \
docker tag hokusai:latest artsy/hokusai:$(VERSION) && \
docker push artsy/hokusai:$(VERSION) && \
docker tag hokusai:latest artsy/hokusai:$(MINOR_VERSION) && \
docker push artsy/hokusai:$(MINOR_VERSION) && \
docker tag hokusai:latest artsy/hokusai:latest && \
docker push artsy/hokusai:latest; \
else \
echo "Version $(VERSION) already published"; \
exit 1; \
fi
publish-head-dockerhub:
docker tag hokusai:latest artsy/hokusai:head
docker push artsy/hokusai:head
publish-github:
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-$(VERSION)-*" \
s3://artsy-provisioning-public/hokusai/ dist/; \
ghr \
--username artsy \
--repository hokusai \
--name v$(VERSION) \
--soft \
v$(VERSION) dist/
clean:
sudo $(RM) -r ./dist