-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
351 lines (305 loc) · 10.4 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# Go parameters
THIS_FILE := $(lastword $(MAKEFILE_LIST))
GOCMD := go
GOBUILD := $(GOCMD) build
GODEP :=dep
GOINSTALL := $(GOCMD) install
GOLINT := golangci-lint
GOFMT := gofmt
SHELL := /bin/bash
TARGET := $(shell echo $${PWD\#\#*/})
VERSION := 2.1.0
BUILD := `git rev-parse --short HEAD`
LDFLAGS=-ldflags "-X=main.VERSION=$(VERSION) -X=main.BUILD=$(BUILD)"
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
define environment
{
"Variables": {
"AWS_RESOURCE_TAG_NAME_VALUE": "$(AWS_RESOURCE_TAG_NAME_VALUE)",
"ENABLE_LIBRARY_SYNC": "$(ENABLE_LIBRARY_SYNC)",
"DYNAMODB_ENDPOINT": "$(DYNAMODB_ENDPOINT)",
"FLIXCTL_HOST": "$(FLIXCTL_HOST)",
"HOOKS_URL": "$(HOOKS_URL)",
"PLEX_PORT": "$(PLEX_PORT)",
"PLEX_PASSWORD": "$(PLEX_PASSWORD)",
"PLEX_TOKEN": "$(PLEX_TOKEN)",
"PLEX_USER": "$(PLEX_USER)",
"RADARR_API_KEY": "$(RADARR_API_KEY)",
"RADARR_URL": "$(RADARR_URL)",
"SLACK_CLIENT_ID": "$(SLACK_CLIENT_ID)",
"SLACK_CLIENT_SECRET": "$(SLACK_CLIENT_SECRET)",
"SLACK_REDIRECT_URI": "$(SLACK_REDIRECT_URI)",
"SLACK_LEGACY_TOKEN": "$(SLACK_LEGACY_TOKEN)",
"SLACK_GENERAL_HOOK_URL": "$(SLACK_GENERAL_HOOK_URL)",
"SLACK_MONITORING_HOOK_URL": "$(SLACK_MONITORING_HOOK_URL)",
"SLACK_NEW_RELEASES_HOOK_URL": "$(SLACK_NEW_RELEASES_HOOK_URL)",
"SLACK_NOTIFICATION": "$(SLACK_NOTIFICATION)",
"SLACK_REQUESTS_HOOK_URL": "$(SLACK_REQUESTS_HOOK_URL)",
"SLACK_SIGNING_SECRET": "$(SLACK_SIGNING_SECRET)",
"SONARR_API_KEY": "$(SONARR_API_KEY)",
"SONARR_URL": "$(SONARR_URL)",
"TAUTULI_API_KEY": "$(TAUTULI_API_KEY)",
"TRANSMISSION_PORT": "$(TRANSMISSION_PORT)",
"TR_AUTH": "$(TR_AUTH)"
}
}
endef
export environment
.DEFAULT_GOAL: $(TARGET)
all: lint install
$(TARGET): $(SRC)
@go build $(LDFLAGS) -o $(TARGET)
build: clean $(TARGET) build-lambdas
@true
create-deploy-directory:
@mkdir deploy
@cp flixctl deploy
clean:
@rm -f $(TARGET)
@rm -rf $(shell pwd)/aws/lambda/admin/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/admin/admin
@rm -rf $(shell pwd)/aws/lambda/library/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/library/library
@rm -rf $(shell pwd)/aws/lambda/movies/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/movies/movies
@rm -rf $(shell pwd)/aws/lambda/plex/executor/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/plex/executor/executor
@rm -rf $(shell pwd)/aws/lambda/plex/monitor/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/plex/monitor/monitor
@rm -rf $(shell pwd)/aws/lambda/slack/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/slack/slack
@rm -rf $(shell pwd)/aws/lambda/shows/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/shows/shows
@rm -rf $(shell pwd)/aws/lambda/torrent/lambda.zip
@rm -rf $(shell pwd)/aws/lambda/torrent/torrent
env:
@echo "$$environment"
install:
@$(MAKE) -f $(THIS_FILE) update-vendor
@$(GOINSTALL) $(LDFLAGS)
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@$(GOFMT) -l -w $(SRC)
simplify:
@$(GOFMT) -s -l -w $(SRC)
run: install
@$(TARGET)
dep:
@$(GODEP) check
@$(GODEP) ensure -v
lint: fmt simplify
@$(GOLINT) run -v \
--deadline=5m \
--disable gochecknoglobals \
--disable lll \
--max-same-issues 100
update:
@$(GODEP) ensure -update -v
update-vendor:
@cp -R aws/ vendor/github.com/eschizoid/flixctl/aws
@cp -R cmd/ vendor/github.com/eschizoid/flixctl/cmd
@cp -R library/ vendor/github.com/eschizoid/flixctl/library
@cp -R models/ vendor/github.com/eschizoid/flixctl/models
@cp -R slack/ vendor/github.com/eschizoid/flixctl/slack
@cp -R torrent/ vendor/github.com/eschizoid/flixctl/torrent
@cp -R worker/ vendor/github.com/eschizoid/flixctl/worker
build-lambdas: clean \
build-lambda-flixctl-admin-executor \
build-lambda-library-executor \
build-lambda-movies-executor \
build-lambda-plex-executor \
build-lambda-plex-monitor \
build-lambda-shows-executor \
build-lambda-slack-dispatcher \
build-lambda-torrent-executor
build-lambda-flixctl-admin-executor:
@cd $(shell pwd)/aws/lambda/admin; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-library-executor:
@cd $(shell pwd)/aws/lambda/library; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-movies-executor:
@cd $(shell pwd)/aws/lambda/movies; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-plex-executor:
@cd $(shell pwd)/aws/lambda/plex/executor; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-plex-monitor:
@cd $(shell pwd)/aws/lambda/plex/monitor; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-shows-executor:
@cd $(shell pwd)/aws/lambda/shows; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-slack-dispatcher:
@cd $(shell pwd)/aws/lambda/slack; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
build-lambda-torrent-executor:
@cd $(shell pwd)/aws/lambda/torrent; \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD)
zip-lambdas: build-lambdas \
zip-lambda-flixctl-admin-executor \
zip-lambda-library-executor \
zip-lambda-movies-executor \
zip-lambda-plex-executor \
zip-lambda-plex-monitor \
zip-lambda-slack-dispatcher \
zip-lambda-shows-executor \
zip-lambda-torrent-executor
zip-lambda-flixctl-admin-executor:
zip -j -X $(shell pwd)/aws/lambda/admin/lambda.zip \
$(shell pwd)/aws/lambda/admin/admin
zip-lambda-library-executor:
zip -j -X $(shell pwd)/aws/lambda/library/lambda.zip \
$(shell pwd)/aws/lambda/library/library
zip-lambda-movies-executor:
zip -j -X $(shell pwd)/aws/lambda/movies/lambda.zip \
$(shell pwd)/aws/lambda/movies/movies
zip-lambda-plex-executor:
zip -j -X $(shell pwd)/aws/lambda/plex/executor/lambda.zip \
$(shell pwd)/aws/lambda/plex/executor/executor
zip-lambda-plex-monitor:
zip -j -X $(shell pwd)/aws/lambda/plex/monitor/lambda.zip \
$(shell pwd)/aws/lambda/plex/monitor/monitor
zip-lambda-slack-dispatcher:
zip -j -X $(shell pwd)/aws/lambda/slack/lambda.zip \
$(shell pwd)/aws/lambda/slack/slack
zip-lambda-shows-executor:
zip -j -X $(shell pwd)/aws/lambda/shows/lambda.zip \
$(shell pwd)/aws/lambda/shows/shows
zip-lambda-torrent-executor:
zip -j -X $(shell pwd)/aws/lambda/torrent/lambda.zip \
$(shell pwd)/aws/lambda/torrent/torrent
deploy-lambdas: zip-lambdas \
deploy-lambda-flixctl-admin-executor \
deploy-lambda-library-executor \
deploy-lambda-movies-executor \
deploy-lambda-plex-executor \
deploy-lambda-plex-monitor \
deploy-lambda-slack-dispatcher \
deploy-lambda-shows-executor \
deploy-lambda-torrent-executor
delete-lambdas:
@aws lambda delete-function \
--function-name flixctl-admin-executor
@aws lambda delete-function \
--function-name library-executor
@aws lambda delete-function \
--function-name movies-executor
@aws lambda delete-function \
--function-name plex-executor
@aws lambda delete-function \
--function-name plex-monitor
@aws lambda delete-function \
--function-name slack-dispatcher
@aws lambda delete-function \
--function-name shows-executor
@aws lambda delete-function \
--function-name torrent-executor
deploy-lambda-flixctl-admin-executor:
@aws lambda update-function-code \
--function-name flixctl-admin-executor \
--zip-file fileb://$(shell pwd)/aws/lambda/admin/lambda.zip
@aws lambda update-function-configuration \
--function-name flixctl-admin-executor \
--handler admin \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-library-executor:
@aws lambda update-function-code \
--function-name library-executor \
--zip-file fileb://$(shell pwd)/aws/lambda/library/lambda.zip
@aws lambda update-function-configuration \
--function-name library-executor \
--handler library \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-movies-executor:
@aws lambda update-function-code \
--function-name movies-executor \
--zip-file fileb://$(shell pwd)/aws/lambda/movies/lambda.zip
@aws lambda update-function-configuration \
--function-name movies-executor \
--handler movies \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-plex-executor:
@aws lambda update-function-code \
--function-name plex-executor \
--zip-file fileb://$(shell pwd)/aws/lambda/plex/executor/lambda.zip
@aws lambda update-function-configuration \
--function-name plex-executor \
--handler executor \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-plex-monitor:
@aws lambda update-function-code \
--function-name plex-monitor \
--zip-file fileb://$(shell pwd)/aws/lambda/plex/monitor/lambda.zip
@aws lambda update-function-configuration \
--function-name plex-monitor \
--handler monitor \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-slack-dispatcher:
@aws lambda update-function-code \
--function-name slack-dispatcher \
--zip-file fileb://$(shell pwd)/aws/lambda/slack/lambda.zip
@aws lambda update-function-configuration \
--function-name slack-dispatcher \
--handler slack \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-shows-executor:
@aws lambda update-function-code \
--function-name shows-executor \
--zip-file fileb://$(shell pwd)/aws/lambda/shows/lambda.zip
@aws lambda update-function-configuration \
--function-name shows-executor \
--handler shows \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
deploy-lambda-torrent-executor:
@aws lambda update-function-code \
--function-name torrent-executor \
--zip-file fileb://$(shell pwd)/aws/lambda/torrent/lambda.zip
@aws lambda update-function-configuration \
--function-name torrent-executor \
--handler torrent \
--region $(AWS_REGION) \
--role arn:aws:iam::623592657701:role/lambda_basic_execution \
--timeout 900 \
--memory-size 128 \
--runtime go1.x \
--environment "$$environment"
tag:
@git tag --force $(VERSION)
@git push origin --tags --force