-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
48 lines (36 loc) · 1.17 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
INSTALL_PATH ?= /usr/local/bin
GIT_SHA := $(shell git log -1 --pretty=format:"%H")
LD_FLAGS := "-X github.com/massdriver-cloud/airlock/pkg/version.version=dev -X github.com/massdriver-cloud/airlock/pkg/version.gitSHA=local-dev-${GIT_SHA}"
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
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 bin/*
.PHONY: generate
generate: ${API_DIR}/zz_generated.go
.PHONY: test
test:
go clean -testcache && 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/airlock-darwin-arm64 -ldflags=${LD_FLAGS}
.PHONY: build.linux
build.linux: bin
GOOS=linux GOARCH=amd64 go build -o bin/airlock-linux-amd64 -ldflags=${LD_FLAGS}
.PHONY: install.macos
install.macos: build.macos
rm -f ${INSTALL_PATH}/airlock
cp bin/airlock-darwin-arm64 ${INSTALL_PATH}/airlock
.PHONY: install.linux
install.linux: build.linux
cp -f bin/airlock-linux-amd64 ${INSTALL_PATH}/airlock