forked from dnote/dnote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (105 loc) · 3 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
NPM := $(shell command -v npm 2> /dev/null)
GH := $(shell command -v gh 2> /dev/null)
currentDir = $(shell pwd)
serverOutputDir = ${currentDir}/build/server
cliOutputDir = ${currentDir}/build/cli
cliHomebrewDir = ${currentDir}/../homebrew-dnote
## installation
install: install-go install-js
.PHONY: install
install-go:
@echo "==> installing go dependencies"
@go mod download
.PHONY: install-go
install-js:
ifndef NPM
$(error npm is not installed)
endif
@echo "==> installing js dependencies"
ifeq ($(CI), true)
@(cd ${currentDir}/pkg/server/assets && npm ci --cache $(NPM_CACHE_DIR) --prefer-offline --unsafe-perm=true)
else
@(cd ${currentDir}/pkg/server/assets && npm install)
endif
.PHONY: install-js
## test
test: test-cli test-api
.PHONY: test
test-cli:
@echo "==> running CLI test"
@(${currentDir}/scripts/cli/test.sh)
.PHONY: test-cli
test-api:
@echo "==> running API test"
@(${currentDir}/scripts/server/test-local.sh)
.PHONY: test-api
test-selfhost:
@echo "==> running a smoke test for self-hosting"
@${currentDir}/host/smoketest/run_test.sh ${tarballPath}
.PHONY: test-selfhost
# development
dev-server:
@echo "==> running dev environment"
@VERSION=master ${currentDir}/scripts/server/dev.sh
.PHONY: dev-server
build-server:
ifndef version
$(error version is required. Usage: make version=0.1.0 build-server)
endif
@echo "==> building server"
@${currentDir}/scripts/server/build.sh $(version)
.PHONY: build-server
build-cli:
ifeq ($(debug), true)
@echo "==> building cli in dev mode"
@${currentDir}/scripts/cli/dev.sh
else
ifndef version
$(error version is required. Usage: make version=0.1.0 build-cli)
endif
@echo "==> building cli"
@${currentDir}/scripts/cli/build.sh $(version)
endif
.PHONY: build-cli
## release
release-cli: clean build-cli
ifndef version
$(error version is required. Usage: make version=0.1.0 release-cli)
endif
ifndef GH
$(error please install github-cli)
endif
@echo "==> releasing cli"
@${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir}
.PHONY: release-cli
release-cli-homebrew: clean build-cli
ifndef version
$(error version is required. Usage: make version=0.1.0 release-cli)
endif
@echo "==> releasing cli on Homebrew"
@${currentDir}/scripts/cli/release-homebrew.sh $(version) ${cliOutputDir}
.PHONY: release-cli
release-server:
ifndef version
$(error version is required. Usage: make version=0.1.0 release-server)
endif
ifndef GH
$(error please install github-cli)
endif
@echo "==> releasing server"
@${currentDir}/scripts/release.sh server $(version) ${serverOutputDir}
@echo "==> building and releasing docker image"
@(cd ${currentDir}/host/docker && ./build.sh $(version))
@(cd ${currentDir}/host/docker && ./release.sh $(version))
.PHONY: release-server
# migrations
create-migration:
ifndef filename
$(error filename is required. Usage: make filename=your-filename create-migration)
endif
@(cd ${currentDir}/pkg/server/database && ./scripts/create-migration.sh $(filename))
.PHONY: create-migration
clean:
@git clean -f
@rm -rf build
.PHONY: clean