Skip to content

Commit 2bed315

Browse files
committed
fix: release ci process
1 parent 7e215f8 commit 2bed315

File tree

4 files changed

+84
-124
lines changed

4 files changed

+84
-124
lines changed

.github/workflows/cli-release.yaml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# limitations under the License.
1616

1717
# Build and release CLI binaries when cli/* tags are pushed
18-
# Uses GoReleaser for cross-platform builds (standard for kubectl plugins)
1918
name: CLI Release
2019

2120
on:
@@ -34,9 +33,6 @@ jobs:
3433
steps:
3534
- name: Checkout repository
3635
uses: actions/checkout@v4
37-
with:
38-
fetch-depth: 0
39-
fetch-tags: true
4036

4137
- name: Setup Go ${{ env.GO_VERSION }}
4238
uses: actions/setup-go@v5
@@ -47,18 +43,49 @@ jobs:
4743
- name: Extract version from tag
4844
id: version
4945
run: |
50-
# Tag is cli/v0.9.0, extract v0.9.0
51-
VERSION=$(echo "${{ github.ref_name }}" | cut -f 2 -d /)
46+
# Tag is cli/v0.1.0, extract v0.1.0
47+
VERSION="${GITHUB_REF_NAME#cli/}"
5248
echo "version=${VERSION}" >> $GITHUB_OUTPUT
5349
echo "Building CLI version: ${VERSION}"
5450
55-
- name: Run GoReleaser
56-
uses: goreleaser/goreleaser-action@v6
51+
- name: Build CLI binaries
52+
working-directory: operator
53+
run: make cli-release-build CLI_VERSION=${{ steps.version.outputs.version }}
54+
55+
- name: Create GitHub Release
56+
uses: softprops/action-gh-release@v2
5757
with:
58-
distribution: goreleaser
59-
version: "~> v2"
60-
args: release --clean
61-
workdir: operator
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.version }}
58+
tag_name: ${{ github.ref_name }}
59+
name: "Skyhook CLI ${{ steps.version.outputs.version }}"
60+
files: |
61+
operator/dist/*.tar.gz
62+
operator/dist/*.zip
63+
operator/dist/checksums.txt
64+
body: |
65+
## Skyhook CLI ${{ steps.version.outputs.version }}
66+
67+
### Installation
68+
69+
Download and extract the appropriate archive for your platform.
70+
The binary must be named `kubectl-skyhook` for kubectl to discover it as a plugin.
71+
Alternatively, it can be used directly as `skyhook` without kubectl.
72+
73+
```bash
74+
# Linux (amd64)
75+
curl -LO https://github.com/NVIDIA/skyhook/releases/download/${{ github.ref_name }}/skyhook_${{ steps.version.outputs.version }}_linux_amd64.tar.gz
76+
tar -xzf skyhook_${{ steps.version.outputs.version }}_linux_amd64.tar.gz
77+
sudo mv skyhook /usr/local/bin/kubectl-skyhook
78+
79+
# macOS (Apple Silicon)
80+
curl -LO https://github.com/NVIDIA/skyhook/releases/download/${{ github.ref_name }}/skyhook_${{ steps.version.outputs.version }}_darwin_arm64.tar.gz
81+
tar -xzf skyhook_${{ steps.version.outputs.version }}_darwin_arm64.tar.gz
82+
sudo mv skyhook /usr/local/bin/kubectl-skyhook
83+
```
84+
85+
### Verify installation
86+
87+
```bash
88+
kubectl skyhook version --client-only
89+
# Or if installed as 'skyhook':
90+
skyhook version --client-only
91+
```

.github/workflows/operator-ci.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ name: Operator CI
2020
on:
2121
workflow_dispatch: {}
2222
pull_request:
23-
paths:
24-
- operator/**
23+
paths: &operator-paths
24+
- operator/**/*.go
25+
- operator/go.mod
26+
- operator/go.sum
27+
- operator/deps.mk
28+
- operator/config/**
2529
- containers/operator.Dockerfile
2630
- .github/workflows/operator-ci.yaml
2731
- k8s-tests/**
@@ -31,12 +35,7 @@ on:
3135
- main
3236
tags:
3337
- operator/*
34-
paths:
35-
- operator/**/*.go
36-
- containers/operator.Dockerfile
37-
- .github/workflows/operator-ci.yaml
38-
- k8s-tests/**
39-
- chart/**
38+
paths: *operator-paths
4039

4140
## these envs control the build and test process below
4241
env:

operator/.goreleaser.yaml

Lines changed: 0 additions & 101 deletions
This file was deleted.

operator/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ endif
3838

3939
GIT_SHA := $(shell git rev-parse --short HEAD)
4040
GIT_TAG_LAST := $(shell git tag --list 'operator*' --sort=-v:refname | head -n 1 | cut -d/ -f2)
41+
CLI_TAG_LAST := $(shell git tag --list 'cli/*' --sort=-v:refname | head -n 1 | cut -d/ -f2)
4142

4243
## GO Flags
4344
GO_LDFLAGS := -ldflags "-X github.com/NVIDIA/skyhook/operator/internal/version.GIT_SHA=$(GIT_SHA) \
@@ -337,6 +338,40 @@ CLI_LDFLAGS := -ldflags "-X github.com/NVIDIA/skyhook/operator/internal/version.
337338
build-cli: ensure-test-symlinks ## Build CLI binary.
338339
go build $(GOFLAGS) $(CLI_LDFLAGS) -o bin/skyhook cmd/cli/main.go
339340

341+
CLI_VERSION ?= $(CLI_TAG_LAST)
342+
CLI_DIST_DIR ?= dist
343+
cli-release-build: ## Build CLI binaries for all platforms (used by CI release workflow).
344+
@echo "Building CLI $(CLI_VERSION) for all platforms..."
345+
@mkdir -p $(CLI_DIST_DIR)
346+
@# Build for each platform
347+
@for os in linux darwin windows; do \
348+
for arch in amd64 arm64; do \
349+
echo " Building $$os/$$arch..."; \
350+
ext=""; if [ "$$os" = "windows" ]; then ext=".exe"; fi; \
351+
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build $(GOFLAGS) \
352+
-ldflags "-X github.com/NVIDIA/skyhook/operator/internal/version.VERSION=$(CLI_VERSION) -X github.com/NVIDIA/skyhook/operator/internal/version.GIT_SHA=$(GIT_SHA)" \
353+
-o $(CLI_DIST_DIR)/skyhook_$(CLI_VERSION)_$${os}_$${arch}$${ext} cmd/cli/main.go; \
354+
done; \
355+
done
356+
@# Create archives (rename binary to just "skyhook" inside archive)
357+
@echo "Creating archives..."
358+
@cd $(CLI_DIST_DIR) && for os in linux darwin; do \
359+
for arch in amd64 arm64; do \
360+
cp skyhook_$(CLI_VERSION)_$${os}_$${arch} skyhook && \
361+
tar -czf skyhook_$(CLI_VERSION)_$${os}_$${arch}.tar.gz skyhook && \
362+
rm skyhook; \
363+
done; \
364+
done
365+
@cd $(CLI_DIST_DIR) && for arch in amd64 arm64; do \
366+
cp skyhook_$(CLI_VERSION)_windows_$${arch}.exe skyhook.exe && \
367+
zip -q skyhook_$(CLI_VERSION)_windows_$${arch}.zip skyhook.exe && \
368+
rm skyhook.exe; \
369+
done
370+
@# Generate checksums
371+
@echo "Generating checksums..."
372+
@cd $(CLI_DIST_DIR) && shasum -a 256 *.tar.gz *.zip > checksums.txt
373+
@echo "Done! Artifacts in $(CLI_DIST_DIR)/"
374+
340375
build-cli-with-coverage: ensure-test-symlinks ## Build CLI binary with coverage instrumentation.
341376
go build $(GOFLAGS) -cover $(CLI_LDFLAGS) -o bin/skyhook-cover cmd/cli/main.go
342377
@# Ensure bin/skyhook exists (copy from cover binary if not cached) so symlinks work

0 commit comments

Comments
 (0)