-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Makefile
95 lines (72 loc) · 2.15 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
TAGS=netgo osusergo sqlite_omit_load_extension
VERSION=$(shell git describe --tags --abbrev=0 | cut -c 2-)
COMMIT=$(shell git rev-parse --verify HEAD)
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LD_FLAGS=-s -w -linkmode external -extldflags "-static" -X main.BuildDate=$(DATE) -X main.BuildMode=prod -X main.BuildCommit=$(COMMIT) -X main.BuildVersion=$(VERSION)
BUILD_DIR=./build
PWD=$(shell pwd)
GOLANG_CROSS_VERSION=v1.22.0
license-dir:
mkdir -p build/license || true
download-tools:
go install golang.org/x/tools/cmd/[email protected]
go install github.com/99designs/[email protected]
generate-go:
gqlgen
generate-js:
(cd ui && yarn generate)
generate: generate-go generate-js
lint-go:
go vet ./...
goimports -l $(shell find . -type f -name '*.go' -not -path "./vendor/*")
lint-js:
(cd ui && yarn format:check)
(cd ui && yarn lint:check)
lint: lint-go lint-js
format-go:
goimports -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
format-js:
(cd ui && yarn format)
format: format-go format-js
test-go:
go test --race -coverprofile=coverage.txt -covermode=atomic ./...
test-js:
(cd ui && CI=true yarn test)
test: test-go test-js
install-go:
go mod download
install-js:
(cd ui && yarn)
build-js:
(cd ui && yarn build)
pre-build: build-js
build-bin-local: pre-build
CGO_ENABLED=1 go build -a -ldflags '${LD_FLAGS}' -tags '${TAGS}' -o ${BUILD_DIR}/traggo-server
.PHONY: release
release:
docker build -t traggo:build -f docker/Dockerfile.build docker
docker run \
--rm \
-v "$$HOME/.docker/config.json:/root/.docker/config.json" \
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN="$$GITHUB_TOKEN" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $$PWD:/work \
-w /work \
traggo:build \
release --skip-validate --clean
.PHONY: release-snapshot
release-snapshot:
docker build -t traggo:build -f docker/Dockerfile.build docker
docker run \
--rm \
-v "$$HOME/.docker/config.json:/root/.docker/config.json" \
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN="$$GITHUB_TOKEN" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $$PWD:/work \
-w /work \
traggo:build \
release --clean --snapshot
install: install-go install-js
.PHONY: build