-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
58 lines (45 loc) · 1.34 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
INSTALL_PATH ?= /usr/local/bin
GIT_SHA := $(shell git log -1 --pretty=format:"%H")
LD_FLAGS := "-X github.com/massdriver-cloud/mass/pkg/version.version=dev -X github.com/massdriver-cloud/mass/pkg/version.gitSHA=local-dev-${GIT_SHA}"
MASSDRIVER_PATH?=../massdriver
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
API_DIR := pkg/api
all.macos: clean generate install.macos
all.linux: clean generate install.linux
.PHONY: check
check: clean generate test ## Run tests and linter locally
golangci-lint run
.PHONY: clean
clean:
rm -rf ${API_DIR}/schema.graphql
rm -rf ${API_DIR}/zz_generated.go
.PHONY: generate
generate:
./scripts/graphql-gen.sh
cd ${API_DIR} && go generate
.PHONY:
swagger-gen:
swag fmt -g cmd/server.go
swag init -g cmd/server.go --pd --ot go,yaml
.PHONY: test
test:
go test ./... -cover
bin:
mkdir bin
.PHONY: lint
lint:
golangci-lint run
.PHONY: build.macos
build.macos: bin
GOOS=darwin GOARCH=arm64 go build -o bin/mass-darwin-arm64 -ldflags=${LD_FLAGS}
.PHONY: build.linux
build.linux: bin
GOOS=linux GOARCH=amd64 go build -o bin/mass-linux-amd64 -ldflags=${LD_FLAGS}
.PHONY: install.macos
install.macos: build.macos
rm -f ${INSTALL_PATH}/mass
cp bin/mass-darwin-arm64 ${INSTALL_PATH}/mass
.PHONY: install.linux
install.linux: build.linux
cp -f bin/mass-linux-amd64 ${INSTALL_PATH}/mass