diff --git a/.travis.yml b/.travis.yml index b55b629..f4e6861 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ go: 1.9 services: - docker -script: +script: - make builddocker - - if [ -n "$TRAVIS_TAG" ]; then TAG=$TRAVIS_TAG make releases; fi + - if [ -n "$TRAVIS_TAG" ]; then TAG=$TRAVIS_TAG make full-release; fi deploy: - provider: releases diff --git a/Makefile b/Makefile index a242243..a752044 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ DOMAIN="jasonrichardsmith" APP="rbac-view" +HUB="hub-linux-amd64-2.6.0" USERID=$(shell id -u) GROUPID=$(shell id -g) @@ -59,3 +60,31 @@ releases: tar -czvf rbac-view.$(TAG).linux.tar.gz bin/linux/rbac-view tar -czvf rbac-view.$(TAG).windows.tar.gz bin/windows/rbac-view tar -czvf rbac-view.$(TAG).darwin.tar.gz bin/darwin/rbac-view + +.PHONY: krew-index +krew-index: + curl -O -L https://github.com/github/hub/releases/download/v2.6.0/$(HUB).tgz + tar -xzvf $(HUB).tgz + git clone https://github.com/jasonrichardsmith/krew-index.git + $(eval CURRENT_DIR=$(shell pwd)) + $(eval export TAG) + $(eval export WINDOWS_SHA=$(shell sha256sum bin/windows/rbac-view | awk '{ print $$1 }' )) + $(eval export LINUX_SHA=$(shell sha256sum bin/linux/rbac-view | awk '{ print $$1 }' )) + $(eval export DARWIN_SHA=$(shell sha256sum bin/darwin/rbac-view | awk '{ print $$1 }' )) + envsubst < rbac-view.krew.template.yaml > krew-index/plugins/rbac-view.yaml + cd krew-index && \ + git checkout -b $(TAG) && \ + cat plugins/rbac-view.yaml && \ + git add plugins/rbac-view.yaml && \ + git commit -m 'Release $(TAG)' && \ + git remote add krew-index \ + https://$(GITHUB_TOKEN)@github.com/jasonrichardsmith/krew-index.git > /dev/null 2>&1 && \ + git push --quiet --set-upstream krew-index $(TAG) --force + + $(CURRENT_DIR)/$(HUB)/bin/hub pull-request \ + --base="GoogleContainerTools:master" \ + --head="jasonrichardsmith/krew-index:${TAG}" \ + --message="Update rbac-view ${TAG}" + +.PHONY: full-release +full-release: | releases krew-index diff --git a/rbac-view.krew.template.yaml b/rbac-view.krew.template.yaml new file mode 100644 index 0000000..90eb5ff --- /dev/null +++ b/rbac-view.krew.template.yaml @@ -0,0 +1,55 @@ +# Copyright © 2018 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: krew.googlecontainertools.github.com/v1alpha2 +kind: Plugin +metadata: + name: rbac-view +spec: + version: "${TAG}" + shortDescription: A tool to visualize your RBAC permissions. + caveats: | + Run "kubectl rbac-view" to open a browser with an html view of your permissions. + You can find documentation at https://github.com/jasonrichardsmith/rbac-view. + platforms: + - uri: https://github.com/jasonrichardsmith/rbac-view/releases/download/${TRAVIS_TAG}/rbac-view.${TRAVIS_TAG}.darwin.tar.gz + sha256: ${DARWIN_SHA} + bin: rbac-view + files: + - from: bin/darwin/rbac-view + to: rbac-view + selector: + matchLabels: + os: darwin + arch: amd64 + - uri: https://github.com/jasonrichardsmith/rbac-view/releases/download/${TRAVIS_TAG}/rbac-view.${TRAVIS_TAG}.linux.tar.gz + sha256: ${LINUX_SHA} + bin: rbac-view + files: + - from: bin/linux/rbac-view + to: rbac-view + selector: + matchLabels: + os: linux + arch: amd64 + - uri: https://github.com/jasonrichardsmith/rbac-view/releases/download/${TRAVIS_TAG}/rbac-view.${TRAVIS_TAG}.windows.tar.gz + sha256: ${WINDOWS_SHA} + bin: rbac-view + files: + - from: bin/windows/rbac-view + to: rbac-view + selector: + matchLabels: + os: windows + arch: amd64