-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (150 loc) · 4.61 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!make
# Default values, can be overridden either on the command line of make
# or in .env
.PHONY: init vars test coverage \
version vars ps \
build pull changelog \
release push-qa push-prod
VERSION:=$(shell \
docker run --rm -it \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
python-requests update_release.py -v)
init:
ifeq ($(wildcard .env),)
cp .env.sample .env
echo PYTHONPATH=`pwd`/src >> .env
endif
pipenv install --dev --three
test: check-env
flake8 src --max-line-length=120
pytest --cov=src test
coverage: test
coverage html
open htmlcov/index.html
version:
@echo CHANGELOG GENERATOR:
@docker run -it --rm \
-v "$(pwd)":/usr/local/src/your-app \
ferrarimarco/github-changelog-generator:1.14.3 \
--version
@echo ''
@echo APPLICATION:
@echo Version: $(VERSION)
@echo ''
@echo Updating release numbers...
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
python-requests update_release.py
vars: check-env
@echo ' Version: $(VERSION)'
@echo ' PYTHONPATH: $(PYTHONPATH)'
@echo ''
@echo ' GITHUB_OWNER=${GITHUB_OWNER}'
@echo ' GITHUB_REPO=${GITHUB_REPO}'
@echo ' GITHUB_USER=${GITHUB_USER}'
@echo ' GITHUB_KEY=${GITHUB_KEY}'
@echo ' CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN}'
check-env:
ifeq ($(wildcard .env),)
@echo ".env file is missing. Create it from .env.sample"
@exit 1
else
include .env
export
endif
login:
docker login
build:
cd bin && docker build -t python-requests .
pull: build
docker pull ferrarimarco/github-changelog-generator:1.14.3
ps:
# A lightly formatted version of docker ps
docker ps --format 'table {{.Image}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}'
changelog: check-env
@echo updating CHANGELOG...
@docker run -it --rm \
-v $(PWD):/usr/local/src/your-app \
ferrarimarco/github-changelog-generator:1.14.3 \
-u ${GITHUB_OWNER} -p ${GITHUB_REPO} -t ${CHANGELOG_GITHUB_TOKEN}
# update versions
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
python-requests update_release.py
# commit master
git add CHANGELOG.md
git add versions.py
git commit -m "updated CHANGELOG (and version numbers)"
git push
check-release: check-env
# make sure we are in master
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
python-requests update_release.py check --branch=master
# update versions and ask for confirmation
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
python-requests update_release.py
VERSION=$(shell \
docker run --rm -it \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
python-requests update_release.py -v)
@echo Version used will be $(VERSION)
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
python-requests update_release.py confirm
release: check-release
# create branch and tag
git checkout -b release-$(VERSION)
git add .
git commit -m "Prepared release $(VERSION)"
git push --set-upstream origin release-$(VERSION)
git tag $(VERSION)
git tag -f qa-release
git push --tags --force
# updating CHANGELOG
make changelog
# create github release
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
-e GITHUB_USER=${GITHUB_USER} \
-e GITHUB_OWNER=${GITHUB_OWNER} \
-e GITHUB_REPO=${GITHUB_REPO} \
-e GITHUB_KEY=${GITHUB_KEY} \
python-requests update_release.py publish
# git merge master
git checkout master
git merge release-$(VERSION)
git push
push-qa:
# update tags
git tag -f qa-release
git push --tags --force
# updating CHANGELOG
make changelog
push-prod:
@# confirm push to production
@docker run --rm -it \
-v $(PWD)/.git:/usr/src/app/.git \
-v $(PWD)/versions.py:/usr/src/app/versions.py \
-v $(PWD)/bin/update_release.py:/usr/src/app/update_release.py \
python-requests update_release.py confirm --prod
# update tags
git tag -f prod-release
git push --tags --force
# updating CHANGELOG
make changelog