This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
66 lines (56 loc) · 1.76 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
# go option
GO ?= go
SHELL := /usr/bin/env bash
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
PKG := $(GO) mod download
# TODO(jaredallard): infer from Git tag
APP_VERSION := $(shell git describe --match 'v[0-9]*' --tags --abbrev=0 --always HEAD)
LDFLAGS := -w -s -X github.com/tritonmedia/pkg/app.Version=$(APP_VERSION)
GOFLAGS :=
GO_EXTRA_FLAGS := -v
TAGS :=
BINDIR := $(CURDIR)/bin
PKGDIR := github.com/tritonmedia/api
CGO_ENABLED := 1
BENCH_FLAGS := "-bench=Bench $(BENCH_FLAGS)"
TEST_TAGS ?= tm_test
LOG := "$(CURDIR)/scripts/make-log-wrapper.sh"
.PHONY: default
default: build
.PHONY: version
version:
@echo $(APP_VERSION)
.PHONY: pre-commit
pre-commit: fmt
.PHONY: build
build: gobuild
.PHONY: test
test:
./scripts/test.sh
.PHONY: dep
dep:
@$(LOG) info "Installing dependencies using '$(PKG)'"
$(PKG)
.PHONY: gogenerate
gogenerate:
@$(LOG) info "Running 'go generate'"
$(GO) generate ./...
.PHONY: gobuild
gobuild:
@$(LOG) info "Building releases into ./bin"
@mkdir -p $(BINDIR)
CGO_ENABLED=$(CGO_ENABLED) "$(GO)" build -o "$(BINDIR)/" -ldflags "$(LDFLAGS)" $(GO_EXTRA_FLAGS) "$(PKGDIR)/..."
.PHONY: docker-build-push
docker-build-push:
@$(LOG) info "Building and push docker image"
docker buildx build --platform amd64,arm64 -t "tritonmedia/api:$(APP_VERSION)" --push .
.PHONY: fmt
fmt:
@$(LOG) info "Running goimports"
find . -path ./vendor -prune -o -type f -name '*.go' -print | xargs ./scripts/gobin.sh golang.org/x/tools/cmd/goimports -w
@$(LOG) info "Running shfmt"
./scripts/gobin.sh mvdan.cc/sh/v3/cmd/shfmt -l -w -s .
.PHONY: grpcui
grpcui:
./scripts/gobin.sh github.com/fullstorydev/grpcui/cmd/grpcui -plaintext 127.0.0.1:8000