Skip to content

Commit

Permalink
Add make target for krew (#70)
Browse files Browse the repository at this point in the history
* Add make target for krew

Signed-off-by: Dominique Vernier <[email protected]>

* Update changelog and version

Signed-off-by: Dominique Vernier <[email protected]>
  • Loading branch information
itdove authored Oct 15, 2021
1 parent d275d82 commit d194bc7
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
bin/clusteradm_linux_s390x.tar.gz
bin/clusteradm_windows_amd64.zip
draft: true
prerelease: true
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test/unit/tmp
test/functional/tmp
test/out
/bin
/krew-manifest.yaml

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand Down
37 changes: 37 additions & 0 deletions .krew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright Contributors to the Open Cluster Management project

apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: clusteradm
spec:
version: {{ .TagName }}
homepage: https://github.com/open-cluster-management-io/clusteradm
shortDescription: Provides commands for OCM.
description: |
This plugin allows you to manage clusters on the open-cluster-management platform.
platforms:
- selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/open-cluster-management-io/clusteradm/releases/download/{{ .TagName }}/clusteradm_darwin_amd64.tar.gz" .TagName }}
bin: clusteradm
- selector:
matchLabels:
os: linux
arch: amd64
{{addURIAndSha "https://github.com/open-cluster-management-io/clusteradm/releases/download/{{ .TagName }}/clusteradm_linux_amd64.tar.gz" .TagName }}
bin: clusteradm
- selector:
matchLabels:
os: linux
arch: arm64
{{addURIAndSha "https://github.com/open-cluster-management-io/clusteradm/releases/download/{{ .TagName }}/clusteradm_linux_arm64.tar.gz" .TagName }}
bin: clusteradm
- selector:
matchLabels:
os: windows
arch: amd64
{{addURIAndSha "https://github.com/open-cluster-management-io/clusteradm/releases/download/{{ .TagName }}/clusteradm_windows_amd64.zip" .TagName }}
bin: clusteradm.exe
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[comment]: # ( Copyright Contributors to the Open Cluster Management project )
# Release Content
## Additions
- Add `clusteradm install addons` and `clusteradm enable addons` [Add subcommand to enable application management addon](https://github.com/open-cluster-management-io/clusteradm/issues/45)
- [Add a watch to monitor the deployment of the join on the spoke cluster #9](https://github.com/open-cluster-management-io/clusteradm/issues/9)
- [Add unjoin feature #49](https://github.com/open-cluster-management-io/clusteradm/issues/49)

## Breaking Changes

## Changes

- Add a check to verify the readyness of the CRD

## Bug Fixes
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SCRIPTS_PATH ?= build
INSTALL_DEPENDENCIES ?= ${SCRIPTS_PATH}/install-dependencies.sh

GOPATH := ${shell go env GOPATH}
GOOS := ${shell go env GOOS}
GOARCH := ${shell go env GOARCH}

export PROJECT_DIR = $(shell 'pwd')
export PROJECT_NAME = $(shell basename ${PROJECT_DIR})
Expand All @@ -33,12 +35,39 @@ build:
build-bin:
@rm -rf bin
@mkdir -p bin
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm_darwin_amd64 ./cmd/clusteradm.go && tar -czf bin/clusteradm_darwin_amd64.tar.gz -C bin/ clusteradm_darwin_amd64
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm_linux_amd64 ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_amd64.tar.gz -C bin/ clusteradm_linux_amd64
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm_linux_arm64 ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_arm64.tar.gz -C bin/ clusteradm_linux_arm64
GOOS=linux GOARCH=ppc64le go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm_linux_ppc64le ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_ppc64le.tar.gz -C bin/ clusteradm_linux_ppc64le
GOOS=linux GOARCH=s390x go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm_linux_s390x ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_s390x.tar.gz -C bin/ clusteradm_linux_s390x
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm_windows_amd64.exe ./cmd/clusteradm.go && zip -q bin/clusteradm_windows_amd64.zip -j bin/clusteradm_windows_amd64.exe
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm ./cmd/clusteradm.go && tar -czf bin/clusteradm_darwin_amd64.tar.gz LICENSE -C bin/ clusteradm
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_amd64.tar.gz LICENSE -C bin/ clusteradm
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_arm64.tar.gz LICENSE -C bin/ clusteradm
GOOS=linux GOARCH=ppc64le go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_ppc64le.tar.gz LICENSE -C bin/ clusteradm
GOOS=linux GOARCH=s390x go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm ./cmd/clusteradm.go && tar -czf bin/clusteradm_linux_s390x.tar.gz LICENSE -C bin/ clusteradm
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -gcflags=-trimpath=x/y -o bin/clusteradm.exe ./cmd/clusteradm.go && zip -q bin/clusteradm_windows_amd64.zip LICENSE -j bin/clusteradm.exe

.PHONY: release
release:
@if [[ -z "${VERSION}" ]]; then VERSION=`cat VERSION.txt`; echo $$VERSION; fi; \
git tag v$$VERSION && git push upstream --tags

.PHONY: build-krew
build-krew: krew-tools
@if [[ -z "${VERSION}" ]]; then VERSION=`cat VERSION.txt`; echo $$VERSION; fi; \
docker run -v ${PROJECT_DIR}/.krew.yaml:/tmp/template-file.yaml rajatjindal/krew-release-bot:v0.0.40 \
krew-release-bot template --tag v$$VERSION --template-file /tmp/template-file.yaml > krew-manifest.yaml;
KREW=/tmp/krew-${GOOS}\_$(GOARCH) && \
KREW_ROOT=`mktemp -d` KREW_OS=darwin KREW_ARCH=amd64 $$KREW install --manifest=krew-manifest.yaml && \
KREW_ROOT=`mktemp -d` KREW_OS=linux KREW_ARCH=amd64 $$KREW install --manifest=krew-manifest.yaml && \
KREW_ROOT=`mktemp -d` KREW_OS=linux KREW_ARCH=arm64 $$KREW install --manifest=krew-manifest.yaml && \
KREW_ROOT=`mktemp -d` KREW_OS=windows KREW_ARCH=amd64 $$KREW install --manifest=krew-manifest.yaml;

.PHONY: krew-tools
krew-tools:
ifeq (, $(shell which /tmp/krew-$(GOOS)\_$(GOARCH)))
@( \
set -x; cd /tmp && \
KREW=krew-$(GOOS)\_$(GOARCH); \
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/$$KREW.tar.gz" && \
tar zxvf $$KREW.tar.gz \
)
endif

.PHONY: install
install: build
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0-alpha.5
0.1.0-alpha.6

0 comments on commit d194bc7

Please sign in to comment.