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 17, 2023
1 parent 796fc0f commit 9075f91
Show file tree
Hide file tree
Showing 2 changed files with 50 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-*
54 changes: 42 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 @@ -14,6 +22,17 @@ BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x
export DOCKER_CLI_EXPERIMENTAL=enabled

ALL_BINARIES_PLATFORMS= \
linux/amd64 \
linux/arm \
linux/arm64 \
linux/ppc64le \
linux/s390x \
darwin/amd64 \
darwin/arm64 \
windows/amd64 \
windows/arm64

# Tools versions
# --------------
GOLANGCI_VERSION:=1.53.2
Expand All @@ -35,8 +54,19 @@ 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) build

.PHONY: build
build: $(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: build-all
build-all:
@for platform in $(ALL_BINARIES_PLATFORMS); do \
OS="$${platform%/*}" ARCH="$${platform#*/}" $(MAKE) build; \
done

# Image Rules
# -----------
Expand Down Expand Up @@ -90,10 +120,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 +142,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 9075f91

Please sign in to comment.