-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
66 lines (49 loc) · 1.44 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
MACOS_SERVICE=local.golangid
PROGRAM_NAME=www-golangid
.PHONY: all
all: install
.PHONY: clean
clean:
go clean -i ./cmd/$(PROGRAM_NAME)
rm -f ./$(PROGRAM_NAME)
find ./content -name "*.html" -delete
.PHONY: embed
embed:
go run ./cmd/www-golangid embed
.PHONY: build
build: embed
go build ./cmd/$(PROGRAM_NAME)
.PHONY: install
install: embed
go install ./cmd/$(PROGRAM_NAME)
.PHONY: dev
dev:
go run ./cmd/$(PROGRAM_NAME) -dev
##---- Deployment.
.PHONY: deploy-build
deploy-build: embed
unset CGO_ENABLED; \
GOOS=linux GOARCH=amd64 go build ./cmd/$(PROGRAM_NAME)
.PHONY: deploy-remote
deploy-remote: deploy-build
rsync --progress ./$(PROGRAM_NAME) golang-id.org:/data/app/bin/
##---- Local installation.
.PHONY: install-local
install-local: deploy-local
sudo cp ./cmd/$(PROGRAM_NAME)/$(PROGRAM_NAME).path /etc/systemd/system/
sudo cp ./cmd/$(PROGRAM_NAME)/$(PROGRAM_NAME).service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable $(PROGRAM_NAME)
sudo systemctl start $(PROGRAM_NAME)
##---- Local installation on macos.
.PHONY: macos-install-local
macos-install-local:
cp cmd/$(PROGRAM_NAME)/$(MACOS_SERVICE).plist ~/Library/LaunchAgents/
mkdir -p ~/bin
CGO_ENABLED=0 go build ./cmd/www-golangid
mv $(PROGRAM_NAME) ~/bin/
launchctl load ~/Library/LaunchAgents/$(MACOS_SERVICE).plist
launchctl start $(MACOS_SERVICE)
.PHONY: macos-deploy-local
macos-deploy-local: build
sudo cp -f ./$(PROGRAM_NAME) /usr/local/bin/