diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cd9aff38c..b0460baae 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,9 +23,14 @@ jobs: uses: actions/setup-go@v4 with: go-version: '1.20' - - name: Generate release artifacts - run: | - make release + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + distribution: goreleaser + version: latest + args: release --timeout 60m + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create draft GH release uses: softprops/action-gh-release@v1 with: @@ -33,4 +38,5 @@ jobs: files: | out/operator-components.yaml out/package/* + dist/*.tar.gz body: "TODO: Add release notes here." diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..8d2e34c96 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,21 @@ +before: + hooks: + - make release + +builds: +- id: "clusterctl-operator" + main: ./cmd/plugin + binary: bin/clusterctl-operator + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 +archives: +- id: clusterctl-operator + builds: + - clusterctl-operator + name_template: "clusterctl-operator_{{ .Tag }}_{{ .Os }}_{{ .Arch }}" + wrap_in_directory: false diff --git a/.krew.yaml b/.krew.yaml new file mode 100644 index 000000000..05776db93 --- /dev/null +++ b/.krew.yaml @@ -0,0 +1,42 @@ +apiVersion: krew.googlecontainertools.github.com/v1alpha2 +kind: Plugin +metadata: + name: operator +spec: + version: {{ .TagName }} + homepage: https://github.com/kubernetes-sigs/cluster-api-operator + shortDescription: Use this clusterctl plugin to bootstrap a management cluster for Cluster API with the Cluster API Operator. + description: | + Use this clusterctl plugin to bootstrap a management cluster for Cluster API with the Cluster API Operator. + platforms: + - selector: + matchLabels: + os: darwin + arch: amd64 + {{addURIAndSha "https://github.com/kubernetes-sigs/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_darwin_amd64.tar.gz" .TagName }} + bin: clusterctl-operator + - selector: + matchLabels: + os: darwin + arch: arm64 + {{addURIAndSha "https://github.com/kubernetes-sigs/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_darwin_arm64.tar.gz" .TagName }} + bin: clusterctl-operator + - selector: + matchLabels: + os: linux + arch: amd64 + {{addURIAndSha "https://github.com/kubernetes-sigs/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_linux_amd64.tar.gz" .TagName }} + bin: clusterctl-operator + - selector: + matchLabels: + os: linux + arch: arm64 + {{addURIAndSha "https://github.com/kubernetes-sigs/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_linux_arm64.tar.gz" .TagName }} + bin: clusterctl-operator + - selector: + matchLabels: + os: windows + arch: amd64 + {{addURIAndSha "https://github.com/kubernetes-sigs/cluster-api-operator/releases/download/{{ .TagName }}/clusterctl-operator_{{ .TagName }}_windows_amd64.tar.gz" .TagName }} + bin: clusterctl-operator.exe + diff --git a/Makefile b/Makefile index 635fa2af2..6990826ed 100644 --- a/Makefile +++ b/Makefile @@ -494,8 +494,9 @@ release-alias-tag: # Adds the tag to the last build tag. upload-staging-artifacts: ## Upload release artifacts to the staging bucket gsutil cp $(RELEASE_DIR)/* gs://$(STAGING_BUCKET)/components/$(RELEASE_ALIAS_TAG)/ -.PHONY: update-helm-repo -update-helm-repo: +.PHONY: update-helm-plugin-repo +update-helm-plugin-repo: + ./hack/update-plugin-yaml.sh $(RELEASE_TAG) ./hack/update-helm-repo.sh $(RELEASE_TAG) .PHONY: promote-images diff --git a/docs/release.md b/docs/release.md index b544d452a..8e8783329 100644 --- a/docs/release.md +++ b/docs/release.md @@ -45,11 +45,11 @@ docker pull registry.k8s.io/capi-operator/cluster-api-operator:${RELEASE_TAG} 4. Publish the release on Github. -5. After release was published, switch back to main branch and update index.yaml. It's the source for operator helm chart repository. +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. ```bash git checkout main -make update-helm-repo +make update-helm-plugin-repo ``` 6. Create a PR with the changes. diff --git a/hack/update-plugin-yaml.sh b/hack/update-plugin-yaml.sh new file mode 100755 index 000000000..0caab0bb4 --- /dev/null +++ b/hack/update-plugin-yaml.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -o errexit +set -o pipefail + +REPO_ROOT=$(dirname "${BASH_SOURCE}")/.. + +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 \ No newline at end of file