Skip to content

Commit

Permalink
Add release binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Aug 1, 2023
1 parent 796fc0f commit 8cca191
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ jobs:
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
- name: Build manifests
run: make release-manifests
- name: Release
- name: Release manifests
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: |
_output/components.yaml
_output/high-availability.yaml
_output/high-availability-1.21+.yaml
- name: Build binaries
run: make binary-all
- name: Release binaries
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: |
_output/metrics-server-*
51 changes: 39 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# --------------------------
REGISTRY?=gcr.io/k8s-staging-metrics-server
ARCH?=amd64
OS?=linux
BINARY_NAME?=metrics-server-$(OS)-$(ARCH)

ifeq ($(OS),windows)
BINARY_NAME:=$(BINARY_NAME).exe
endif

OUTPUT_DIR?=_output

# Release variables
# ------------------
Expand All @@ -12,6 +20,7 @@ BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Consts
# ------
ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x
ALL_PLATFORMS=linux darwin windows
export DOCKER_CLI_EXPERIMENTAL=enabled

# Tools versions
Expand All @@ -23,6 +32,8 @@ GOLANGCI_VERSION:=1.53.2
GOPATH:=$(shell go env GOPATH)
REPO_DIR:=$(shell pwd)

ALL_GO_DIST:=$(shell go tool dist list)

.PHONY: all
all: metrics-server

Expand All @@ -35,8 +46,24 @@ PKG:=k8s.io/client-go/pkg
VERSION_LDFLAGS:=-X $(PKG)/version.gitVersion=$(GIT_TAG) -X $(PKG)/version.gitCommit=$(GIT_COMMIT) -X $(PKG)/version.buildDate=$(BUILD_DATE)
LDFLAGS:=-w $(VERSION_LDFLAGS)

metrics-server: $(SRC_DEPS)
GOARCH=$(ARCH) CGO_ENABLED=0 go build -mod=readonly -ldflags "$(LDFLAGS)" -o metrics-server sigs.k8s.io/metrics-server/cmd/metrics-server
metrics-server:
OUTPUT_DIR=. BINARY_NAME=$@ make binary

.PHONY: binary
binary: $(SRC_DEPS)
@mkdir -p $(OUTPUT_DIR)
GOARCH=$(ARCH) GOOS=$(OS) CGO_ENABLED=0 go build -mod=readonly -ldflags "$(LDFLAGS)" -o "$(OUTPUT_DIR)/$(BINARY_NAME)" sigs.k8s.io/metrics-server/cmd/metrics-server

.PHONY: binary-all
binary-all:
@for arch in $(ALL_ARCHITECTURES); do \
for platform in $(ALL_PLATFORMS); do \
if ! grep -q "$${platform}/$${arch}" <<< "$(ALL_GO_DIST)"; then \
continue; \
fi; \
ARCH=$${arch} OS=$${platform} make binary; \
done; \
done

# Image Rules
# -----------
Expand Down Expand Up @@ -90,10 +117,10 @@ release-tag:

.PHONY: release-manifests
release-manifests:
mkdir -p _output
kubectl kustomize manifests/overlays/release > _output/components.yaml
kubectl kustomize manifests/overlays/release-ha > _output/high-availability.yaml
kubectl kustomize manifests/overlays/release-ha-1.21+ > _output/high-availability-1.21+.yaml
mkdir -p $(OUTPUT_DIR)
kubectl kustomize manifests/overlays/release > $(OUTPUT_DIR)/components.yaml
kubectl kustomize manifests/overlays/release-ha > $(OUTPUT_DIR)/high-availability.yaml
kubectl kustomize manifests/overlays/release-ha-1.21+ > $(OUTPUT_DIR)/high-availability-1.21+.yaml


# fuzz tests
Expand All @@ -112,22 +139,22 @@ test-unit:
# Benchmarks
# ----------

HAS_BENCH_STORAGE=$(wildcard ./_output/bench_storage.txt)
HAS_BENCH_STORAGE=$(wildcard ./$(OUTPUT_DIR)/bench_storage.txt)

.PHONY: bench-storage
bench-storage: benchstat
@mkdir -p _output
@mkdir -p $(OUTPUT_DIR)
ifneq ("$(HAS_BENCH_STORAGE)","")
@mv _output/bench_storage.txt _output/bench_storage.old.txt
@mv $(OUTPUT_DIR)/bench_storage.txt $(OUTPUT_DIR)/bench_storage.old.txt
endif
@go test ./pkg/storage/ -bench=. -run=^$ -benchmem -count 5 -timeout 1h | tee _output/bench_storage.txt
@go test ./pkg/storage/ -bench=. -run=^$ -benchmem -count 5 -timeout 1h | tee $(OUTPUT_DIR)/bench_storage.txt
ifeq ("$(HAS_BENCH_STORAGE)","")
@cp _output/bench_storage.txt _output/bench_storage.old.txt
@cp $(OUTPUT_DIR)/bench_storage.txt $(OUTPUT_DIR)/bench_storage.old.txt
endif
@echo
@echo 'Comparing versus previous run. When optimizing copy everything below this line and include in PR description.'
@echo
@benchstat _output/bench_storage.old.txt _output/bench_storage.txt
@benchstat $(OUTPUT_DIR)/bench_storage.old.txt $(OUTPUT_DIR)/bench_storage.txt

HAS_BENCHSTAT:=$(shell which benchstat)
.PHONY: benchstat
Expand Down

0 comments on commit 8cca191

Please sign in to comment.