forked from cilium/tetragon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.cli
51 lines (45 loc) · 1.49 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
# 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.22.2-alpine@sha256:cdc86d9f363e8786845bea2040312b4efa321b828acdeb26f393faa864d887b0
TARGET=tetra
RELEASE_UID ?= $(shell id -u)
RELEASE_GID ?= $(shell id -g)
cli-release:
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}"
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; \
cli-clean:
rm -rf ./release
.PHONY: cli-release cli-local-release