Skip to content

Commit 8abf2de

Browse files
Allow clusterctl plugn to be installed with krew
1 parent d815bcb commit 8abf2de

File tree

6 files changed

+85
-7
lines changed

6 files changed

+85
-7
lines changed

.github/workflows/release.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ jobs:
2323
uses: actions/setup-go@v4
2424
with:
2525
go-version: '1.20'
26-
- name: Generate release artifacts
27-
run: |
28-
make release
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v3
28+
with:
29+
distribution: goreleaser
30+
version: latest
31+
args: release --timeout 60m
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2934
- name: Create draft GH release
3035
uses: softprops/action-gh-release@v1
3136
with:
3237
draft: true
3338
files: |
3439
out/operator-components.yaml
3540
out/package/*
41+
dist/*.tar.gz
3642
body: "TODO: Add release notes here."

.goreleaser.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
before:
2+
hooks:
3+
- make release
4+
5+
builds:
6+
- id: "clusterctl-operator"
7+
main: ./cmd/plugin
8+
binary: bin/clusterctl-operator
9+
goos:
10+
- linux
11+
- darwin
12+
- windows
13+
goarch:
14+
- amd64
15+
- arm64
16+
archives:
17+
- id: clusterctl-operator
18+
builds:
19+
- clusterctl-operator
20+
name_template: "clusterctl-operator_{{ .Tag }}_{{ .Os }}_{{ .Arch }}"
21+
wrap_in_directory: false

.krew.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: krew.googlecontainertools.github.com/v1alpha2
2+
kind: Plugin
3+
metadata:
4+
name: operator
5+
spec:
6+
version: {{ .TagName }}
7+
homepage: https://github.com/Danil-Grigorev/cluster-api-operator
8+
shortDescription: Use this clusterctl plugin to bootstrap a management cluster for Cluster API with the Cluster API Operator.
9+
description: |
10+
Use this clusterctl plugin to bootstrap a management cluster for Cluster API with the Cluster API Operator.
11+
platforms:
12+
- selector:
13+
matchLabels:
14+
os: darwin
15+
arch: amd64
16+
{{addURIAndSha "https://github.com/Danil-Grigorev/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_darwin_amd64.tar.gz" .TagName }}
17+
bin: clusterctl-operator
18+
- selector:
19+
matchLabels:
20+
os: darwin
21+
arch: arm64
22+
{{addURIAndSha "https://github.com/Danil-Grigorev/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_darwin_arm64.tar.gz" .TagName }}
23+
bin: clusterctl-operator
24+
- selector:
25+
matchLabels:
26+
os: linux
27+
arch: amd64
28+
{{addURIAndSha "https://github.com/Danil-Grigorev/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_linux_amd64.tar.gz" .TagName }}
29+
bin: clusterctl-operator
30+
- selector:
31+
matchLabels:
32+
os: linux
33+
arch: arm64
34+
{{addURIAndSha "https://github.com/Danil-Grigorev/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_linux_arm64.tar.gz" .TagName }}
35+
bin: clusterctl-operator
36+
- selector:
37+
matchLabels:
38+
os: windows
39+
arch: amd64
40+
{{addURIAndSha "https://github.com/Danil-Grigorev/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_windows_amd64.tar.gz" .TagName }}
41+
bin: clusterctl-operator.exe
42+

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,9 @@ release-alias-tag: # Adds the tag to the last build tag.
494494
upload-staging-artifacts: ## Upload release artifacts to the staging bucket
495495
gsutil cp $(RELEASE_DIR)/* gs://$(STAGING_BUCKET)/components/$(RELEASE_ALIAS_TAG)/
496496

497-
.PHONY: update-helm-repo
498-
update-helm-repo:
497+
.PHONY: update-helm-plugin-repo
498+
update-helm-plugin-repo:
499+
./hack/update-plugin-yaml.sh $(RELEASE_TAG)
499500
./hack/update-helm-repo.sh $(RELEASE_TAG)
500501

501502
.PHONY: promote-images

docs/release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ docker pull registry.k8s.io/capi-operator/cluster-api-operator:${RELEASE_TAG}
4545

4646
4. Publish the release on Github.
4747

48-
5. After release was published, switch back to main branch and update index.yaml. It's the source for operator helm chart repository.
48+
5. After release was published, switch back to main branch and update index.yaml and clusterctl-operator.yaml. It's the source for operator helm chart repository and local krew plugin manifest index.
4949

5050
```bash
5151
git checkout main
52-
make update-helm-repo
52+
make update-helm-plugin-repo
5353
```
5454

5555
6. Create a PR with the changes.

hack/update-plugin-yaml.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
REPO_ROOT=$(dirname "${BASH_SOURCE}")/..
7+
8+
docker run --rm -v $REPO_ROOT:/home/app ghcr.io/rajatjindal/krew-release-bot:v0.0.46 krew-release-bot template --tag $1 --template-file .krew.yaml > $REPO_ROOT/plugins/clusterctl-operator.yaml

0 commit comments

Comments
 (0)