This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (41 loc) · 1.65 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
GOOS ?= "linux"
GOARCH ?= $(shell go env GOARCH)
ifeq ($(GOARCH),amd64)
LINUX_ARCH = x86_64
else ifeq ($(GOARCH),arm64)
LINUX_ARCH = aarch64
endif
GIT_REVISION = $(shell git rev-parse HEAD | tr -d '\n')
TAG_VERSION ?= $(shell git tag --points-at | sort -Vr | head -n1 | cut -c2-)
ifeq ($(TAG_VERSION),)
PATH_VERSION = custom
else
PATH_VERSION = v$(TAG_VERSION)
endif
LDFLAGS = "-s -w -X 'github.com/viamrobotics/agent-syscfg.Version=${TAG_VERSION}' -X 'github.com/viamrobotics/agent-syscfg.GitRevision=${GIT_REVISION}'"
TAGS = osusergo,netgo
.DEFAULT_GOAL := bin/viam-agent-syscfg-$(PATH_VERSION)-$(LINUX_ARCH)
.PHONY: all
all: amd64 arm64
.PHONY: arm64
arm64:
make GOARCH=arm64
.PHONY: amd64
amd64:
make GOARCH=amd64
bin/viam-agent-syscfg-$(PATH_VERSION)-$(LINUX_ARCH): go.* *.go */*/*.go
go build -o $@ -tags $(TAGS) -ldflags $(LDFLAGS) ./cmd/viam-agent-syscfg/main.go
test "$(PATH_VERSION)" != "custom" && cp $@ bin/viam-agent-syscfg-stable-$(LINUX_ARCH) || true
.PHONY: clean
clean:
rm -rf bin/
bin/golangci-lint:
GOBIN=`pwd`/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
.PHONY: lint
lint: bin/golangci-lint
go mod tidy
bin/golangci-lint run -v --fix
.PHONY: upload-stable
upload-stable: bin/viam-agent-syscfg-$(PATH_VERSION)-x86_64 bin/viam-agent-syscfg-$(PATH_VERSION)-aarch64 bin/viam-agent-syscfg-stable-x86_64 bin/viam-agent-syscfg-stable-aarch64
test "$(PATH_VERSION)" != "custom"
gsutil -h "Cache-Control:no-cache" cp bin/viam-agent-syscfg-$(PATH_VERSION)-x86_64 bin/viam-agent-syscfg-$(PATH_VERSION)-aarch64 bin/viam-agent-syscfg-stable-x86_64 bin/viam-agent-syscfg-stable-aarch64 gs://packages.viam.com/apps/viam-agent-syscfg/