-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (52 loc) · 1.67 KB
/
Makefile
File metadata and controls
68 lines (52 loc) · 1.67 KB
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
# Copyright 2023 The Glove Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
ifndef VCS_COMMIT
VCS_COMMIT := $(shell git rev-parse HEAD)
endif
ifndef VCS_BRANCH
VCS_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
endif
ifndef VCS_TAG
VCS_TAG := $(shell git describe --tags --abbrev 2>/dev/null || echo -n "v0.0.0")
endif
ifndef BUILD_TIME
BUILD_TIME := $(shell date --utc --iso-8601=seconds)
endif
ifndef BUILD_ENVIRONMENT
BUILD_ENVIRONMENT := local
endif
VERSION_PACKAGE = "github.com/pmateusz/glove/internal/version"
LDFLAGS = "-X ${VERSION_PACKAGE}.commitHash=${VCS_COMMIT} \
-X ${VERSION_PACKAGE}.branch=${VCS_BRANCH} \
-X ${VERSION_PACKAGE}.version=${VCS_TAG} \
-X ${VERSION_PACKAGE}.buildTime=${BUILD_TIME} \
-X ${VERSION_PACKAGE}.environment=${BUILD_ENVIRONMENT}"
.PHONY: build clean cli deps-install deps-update format image lint test test-cover update
cli: deps-install build
format:
gofmt -l -s -w .
lint:
go vet ./...
staticcheck ./...
test:
go test ./...
test-cover:
go test ./... -coverpkg=github.com/pmateusz/glove/internal/...,github.com/pmateusz/glove/pkg/... -coverprofile=coverage.out
deps-install:
go get ./...
deps-update:
go get -u ./...
build:
echo $(LDFLAGS)
go generate && go build -ldflags=$(LDFLAGS) -o ./bin/glove ./cmd/glove/main.go
clean:
rm ./bin/glove
image:
docker buildx build --platform linux/amd64 \
--build-arg="VCS_COMMIT=${VCS_COMMIT}" \
--build-arg="VCS_BRANCH=${VCS_BRANCH}" \
--build-arg="VCS_TAG=${VCS_TAG}" \
--build-arg="BUILD_TIME=${BUILD_TIME}" \
--build-arg="BUILD_ENVIRONMENT=${BUILD_ENVIRONMENT}" \
-t glove -f ./build/Dockerfile . \
--load