-
Notifications
You must be signed in to change notification settings - Fork 362
/
Makefile.cli
54 lines (48 loc) · 1.56 KB
/
Makefile.cli
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
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Tetragon
CLI_GO_BUILD = CGO_ENABLED=0 $(GO) build
# renovate: datasource=docker
GO_IMAGE = docker.io/library/golang:1.23.2-alpine@sha256:9dd2625a1ff2859b8d8b01d8f7822c0f528942fe56cfe7a1e7c38d3b8d72d679
TARGET=tetra
RELEASE_UID ?= $(shell id -u)
RELEASE_GID ?= $(shell id -g)
##@ CLI
.PHONY: cli-release
cli-release: ## Compile tetra CLI release binaries.
docker run \
--rm \
--workdir /tetragon \
--volume `pwd`:/tetragon $(GO_IMAGE) \
sh -c "apk add --no-cache make git setpriv && \
/usr/bin/setpriv --reuid=$(RELEASE_UID) --regid=$(RELEASE_GID) --clear-groups \
make GOCACHE=/tmp/cache cli-local-release VERSION=${VERSION}"
.PHONY: cli-local-release
cli-local-release: cli-clean
set -o errexit; \
for OS in darwin linux windows; do \
EXT=; \
ARCHS=; \
case $$OS in \
darwin) \
ARCHS='arm64 amd64'; \
;; \
linux) \
ARCHS='arm64 amd64'; \
;; \
windows) \
ARCHS='arm64 amd64'; \
EXT='.exe'; \
;; \
esac; \
for ARCH in $$ARCHS; do \
echo Building release binary for $$OS/$$ARCH...; \
test -d release/$$OS/$$ARCH|| mkdir -p release/$$OS/$$ARCH; \
env GOOS=$$OS GOARCH=$$ARCH $(CLI_GO_BUILD) -ldflags="$(GO_BUILD_LDFLAGS)" -o release/$$OS/$$ARCH/$(TARGET)$$EXT ./cmd/tetra; \
tar -czf release/$(TARGET)-$$OS-$$ARCH.tar.gz -C release/$$OS/$$ARCH $(TARGET)$$EXT; \
(cd release && sha256sum $(TARGET)-$$OS-$$ARCH.tar.gz > $(TARGET)-$$OS-$$ARCH.tar.gz.sha256sum); \
done; \
rm -r release/$$OS; \
done; \
.PHONY: cli-clean
cli-clean:
rm -rf ./release