Skip to content

Commit 2499d0c

Browse files
committed
2
1 parent 1eb72fc commit 2499d0c

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

.github/workflows/release-cli.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Release CLI Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
env:
10+
GO_VERSION: 1.24.1
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release-cli:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
include:
21+
- goos: linux
22+
goarch: amd64
23+
- goos: linux
24+
goarch: arm64
25+
- goos: darwin
26+
goarch: amd64
27+
- goos: darwin
28+
goarch: arm64
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up Go
36+
uses: actions/setup-go@v5
37+
with:
38+
go-version: ${{ env.GO_VERSION }}
39+
40+
- name: Get version info
41+
id: version
42+
run: |
43+
TAG=${GITHUB_REF#refs/tags/}
44+
GIT_COMMIT=$(git rev-parse HEAD)
45+
BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z)
46+
echo "tag=$TAG" >> $GITHUB_OUTPUT
47+
echo "git_commit=$GIT_COMMIT" >> $GITHUB_OUTPUT
48+
echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT
49+
50+
- name: Build CLI binary
51+
env:
52+
GOOS: ${{ matrix.goos }}
53+
GOARCH: ${{ matrix.goarch }}
54+
CGO_ENABLED: '0'
55+
run: |
56+
VERSION_PKG=sigs.k8s.io/rbgs/version
57+
LDFLAGS="-s -w -X ${VERSION_PKG}.Version=${{ steps.version.outputs.tag }} -X ${VERSION_PKG}.GitCommit=${{ steps.version.outputs.git_commit }} -X ${VERSION_PKG}.BuildDate=${{ steps.version.outputs.build_date }}"
58+
BINARY_NAME=kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }}
59+
go build -mod vendor -v -o ${BINARY_NAME} -ldflags "${LDFLAGS}" cmd/cli/main.go
60+
chmod +x ${BINARY_NAME}
61+
62+
# Generate checksum
63+
sha256sum ${BINARY_NAME} > ${BINARY_NAME}.sha256
64+
65+
- name: Upload artifact
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }}
69+
path: |
70+
kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }}
71+
kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }}.sha256
72+
73+
create-release:
74+
needs: release-cli
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Download all artifacts
78+
uses: actions/download-artifact@v4
79+
with:
80+
path: artifacts
81+
merge-multiple: true
82+
83+
- name: Create GitHub Release
84+
uses: softprops/action-gh-release@v2
85+
with:
86+
generate_release_notes: true
87+
files: |
88+
artifacts/kubectl-rbg-*
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ build-cli: ## Build cli binary.
157157
GOPROXY=${GOPROXY} \
158158
go build -mod vendor -v -o bin/kubectl-rbg -ldflags $(ldflags) cmd/cli/main.go
159159

160+
CLI_PLATFORMS ?= linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
161+
162+
.PHONY: build-cli-all
163+
build-cli-all: ## Build cli binaries for all platforms.
164+
@for platform in $(CLI_PLATFORMS); do \
165+
GOOS=$${platform%%/*} GOARCH=$${platform##*/} \
166+
CGO_ENABLED=0 GO111MODULE=on GOPROXY=${GOPROXY} \
167+
go build -mod vendor -v -o bin/kubectl-rbg-$${platform%%/*}-$${platform##*/} -ldflags $(ldflags) cmd/cli/main.go; \
168+
echo "Built bin/kubectl-rbg-$${platform%%/*}-$${platform##*/}"; \
169+
done
170+
160171
.PHONY: build-benchmark-dashboard
161172
build-benchmark-dashboard: ## Build benchmark-dashboard binary.
162173
GOARCH=${TARGETARCH} \

0 commit comments

Comments
 (0)