From a3bbc09cc22aafadd446ca8e20591f93cc4a2399 Mon Sep 17 00:00:00 2001 From: tommyd450 Date: Tue, 31 Oct 2023 14:33:23 +0000 Subject: [PATCH] :open_file_folder: update Red Hat specific files --- Build.mak | 38 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 6 +++++- redhat/overlays/Build.mak | 38 ++++++++++++++++++++++++++++++++++++++ redhat/overlays/Dockerfile | 6 +++++- 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Build.mak create mode 100644 redhat/overlays/Build.mak diff --git a/Build.mak b/Build.mak new file mode 100644 index 00000000000..67e7fbfe830 --- /dev/null +++ b/Build.mak @@ -0,0 +1,38 @@ + +GIT_VERSION ?= $(shell git describe --tags --always --dirty) + +LDFLAGS=-buildid= -X sigs.k8s.io/release-utils/version.gitVersion=$(GIT_VERSION) \ + -X sigs.k8s.io/release-utils/version.gitCommit=$(GIT_HASH) \ + -X sigs.k8s.io/release-utils/version.gitTreeState=$(GIT_TREESTATE) \ + -X sigs.k8s.io/release-utils/version.buildDate=$(BUILD_DATE) + +.PHONY: +cross-platform: cosign-darwin-arm64 cosign-darwin-amd64 cosign-linux-amd64 cosign-linux-arm64 cosign-linux-ppc64le cosign-linux-s390x cosign-windows ## Build all distributable (cross-platform) binaries + +.PHONY: cosign-darwin-arm64 +cosign-darwin-arm64: ## Build for mac M1 + env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o cosign-darwin-arm64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-darwin-amd64 +cosign-darwin-amd64: ## Build for Darwin (macOS) + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o cosign-darwin-amd64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-amd64 +cosign-linux-amd64: ## Build for Linux amd64 + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o cosign-linux-amd64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-arm64 +cosign-linux-arm64: ## Build for Linux arm64 + env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o cosign-linux-arm64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-ppc64le +cosign-linux-ppc64le: ## Build for Linux ppc64le + env CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -o cosign-linux-ppc64le -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-s390x +cosign-linux-s390x: ## Build for Linux s390x + env CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -o cosign-linux-s390x -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-windows +cosign-windows: ## Build for Windows + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o cosign-windows-amd64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e61d80483f5..360c61942ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,11 @@ WORKDIR /cosign COPY . . USER root RUN git config --global --add safe.directory /cosign -RUN make cross + +RUN make cosign-linux-amd64 +RUN make cosign-darwin-amd64 +RUN make cosign-windows + RUN gzip cosign-darwin-amd64 RUN gzip cosign-windows-amd64 diff --git a/redhat/overlays/Build.mak b/redhat/overlays/Build.mak new file mode 100644 index 00000000000..67e7fbfe830 --- /dev/null +++ b/redhat/overlays/Build.mak @@ -0,0 +1,38 @@ + +GIT_VERSION ?= $(shell git describe --tags --always --dirty) + +LDFLAGS=-buildid= -X sigs.k8s.io/release-utils/version.gitVersion=$(GIT_VERSION) \ + -X sigs.k8s.io/release-utils/version.gitCommit=$(GIT_HASH) \ + -X sigs.k8s.io/release-utils/version.gitTreeState=$(GIT_TREESTATE) \ + -X sigs.k8s.io/release-utils/version.buildDate=$(BUILD_DATE) + +.PHONY: +cross-platform: cosign-darwin-arm64 cosign-darwin-amd64 cosign-linux-amd64 cosign-linux-arm64 cosign-linux-ppc64le cosign-linux-s390x cosign-windows ## Build all distributable (cross-platform) binaries + +.PHONY: cosign-darwin-arm64 +cosign-darwin-arm64: ## Build for mac M1 + env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o cosign-darwin-arm64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-darwin-amd64 +cosign-darwin-amd64: ## Build for Darwin (macOS) + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o cosign-darwin-amd64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-amd64 +cosign-linux-amd64: ## Build for Linux amd64 + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o cosign-linux-amd64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-arm64 +cosign-linux-arm64: ## Build for Linux arm64 + env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o cosign-linux-arm64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-ppc64le +cosign-linux-ppc64le: ## Build for Linux ppc64le + env CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -o cosign-linux-ppc64le -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-linux-s390x +cosign-linux-s390x: ## Build for Linux s390x + env CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -o cosign-linux-s390x -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign + +.PHONY: cosign-windows +cosign-windows: ## Build for Windows + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o cosign-windows-amd64 -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/cosign \ No newline at end of file diff --git a/redhat/overlays/Dockerfile b/redhat/overlays/Dockerfile index e61d80483f5..360c61942ad 100644 --- a/redhat/overlays/Dockerfile +++ b/redhat/overlays/Dockerfile @@ -5,7 +5,11 @@ WORKDIR /cosign COPY . . USER root RUN git config --global --add safe.directory /cosign -RUN make cross + +RUN make cosign-linux-amd64 +RUN make cosign-darwin-amd64 +RUN make cosign-windows + RUN gzip cosign-darwin-amd64 RUN gzip cosign-windows-amd64