Skip to content

Commit

Permalink
Use GoReleaser to generate the krew plugin manifest (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
superbrothers authored Dec 18, 2021
1 parent 352e51c commit ed330c6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 278 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: make dist
- run: make release
- uses: softprops/action-gh-release@v1
with:
files: dist/!(config.yaml)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: superbrothers/actions/krew-plugin-test@master
- uses: rajatjindal/krew-[email protected]
with:
manifest: ./dist/sort-manifests.yaml
command: kubectl sort-manifests --help
- uses: superbrothers/actions/krew-plugin-release@master
with:
token: ${{ secrets.PAT }}
plugin_name: sort-manifests
manifest_path: dist/sort-manifests.yaml
git_author_name: Kazuki Suda
git_author_email: [email protected]
krew_template_file: dist/sort-manifests.yaml
14 changes: 13 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ archives:
checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
skip: true
krews:
- name: sort-manifests
homepage: https://github.com/superbrothers/ksort
description: |
When installing manifests, they should be sorted in a proper order by Kind.
For example, Namespace object must be in the first place when installing
them.
ksort sorts manifest files in a proper order by Kind, which is implementd by
using tiller.SortByKind() in Kubernetes Helm.
short_description: Sort manifest files in a proper order by Kind
skip_upload: true
15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
GO ?= go
DIST_DIR := dist
GIT_VERSION ?= $(shell ./hack/git-version.sh)

.PHONY: build
build:
Expand All @@ -12,8 +11,6 @@ GORELEASER_BIN := bin/goreleaser
GORELEASER := $(TOOLS_DIR)/$(GORELEASER_BIN)
GOLANGCI_LINT_BIN := bin/golangci-lint
GOLANGCI_LINT := $(TOOLS_DIR)/$(GOLANGCI_LINT_BIN)
GOMPLATE_BIN := bin/gomplate
GOMPLATE := $(TOOLS_DIR)/$(GOMPLATE_BIN)
VALIDATE_KREW_MAIFEST_BIN := bin/validate-krew-manifest
VALIDATE_KREW_MAIFEST := $(TOOLS_DIR)/$(VALIDATE_KREW_MAIFEST_BIN)

Expand All @@ -23,9 +20,6 @@ $(GORELEASER): $(TOOLS_DIR)/go.mod
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -o $(GOLANGCI_LINT_BIN) github.com/golangci/golangci-lint/cmd/golangci-lint

$(GOMPLATE): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -o $(GOMPLATE_BIN) github.com/hairyhenderson/gomplate/v3/cmd/gomplate

$(VALIDATE_KREW_MAIFEST): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -o $(VALIDATE_KREW_MAIFEST_BIN) sigs.k8s.io/krew/cmd/validate-krew-manifest

Expand Down Expand Up @@ -54,13 +48,12 @@ validate-krew-manifest: $(VALIDATE_KREW_MAIFEST)
$(VALIDATE_KREW_MAIFEST) -manifest dist/sort-manifests.yaml -skip-install

.PHONY: dist
dist: $(GORELEASER) $(GOMPLATE)
dist: $(GORELEASER)
$(GORELEASER) release --rm-dist --skip-publish --snapshot
$(MAKE) manifest

.PHONY: manifest
manifest:
GIT_VERSION=$(GIT_VERSION) $(GOMPLATE) -f ./hack/sort-manifests.yaml.tmpl > $(DIST_DIR)/sort-manifests.yaml
.PHONY: release
release: $(GORELEASER)
$(GORELEASER) release --rm-dist --skip-publish

.PHONY: clean
clean:
Expand Down
24 changes: 0 additions & 24 deletions hack/git-version.sh

This file was deleted.

31 changes: 0 additions & 31 deletions hack/sort-manifests.yaml.tmpl

This file was deleted.

32 changes: 3 additions & 29 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.17
require (
github.com/golangci/golangci-lint v1.43.0
github.com/goreleaser/goreleaser v1.1.0
github.com/hairyhenderson/gomplate/v3 v3.9.0
sigs.k8s.io/krew v0.4.2-0.20211206221333-b015efbdf40d
)

Expand Down Expand Up @@ -35,20 +34,18 @@ require (
github.com/DisgoOrg/disgohook v1.4.3 // indirect
github.com/DisgoOrg/log v1.1.0 // indirect
github.com/DisgoOrg/restclient v1.2.7 // indirect
github.com/Djarvur/go-err113 v0.1.0 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/OpenPeeDeeP/depguard v1.0.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210512092938-c05353c2d58c // indirect
github.com/Shopify/ejson v1.2.2 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/alecthomas/jsonschema v0.0.0-20211022214203-8b29eab41725 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/apex/log v1.9.0 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/ashanbrown/forbidigo v1.2.0 // indirect
github.com/ashanbrown/makezero v0.0.0-20210520155254-b6261585ddde // indirect
github.com/atc0005/go-teams-notify/v2 v2.6.0 // indirect
Expand Down Expand Up @@ -86,8 +83,6 @@ require (
github.com/dghubble/oauth1 v0.7.0 // indirect
github.com/dghubble/sling v1.3.0 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/docker/libkv v0.2.2-0.20180912205406-458977154600 // indirect
github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/esimonov/ifshort v1.0.3 // indirect
github.com/ettle/strcase v0.1.1 // indirect
Expand Down Expand Up @@ -115,7 +110,6 @@ require (
github.com/golang-jwt/jwt/v4 v4.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613 // indirect
Expand All @@ -138,27 +132,16 @@ require (
github.com/goreleaser/fileglob v1.2.0 // indirect
github.com/goreleaser/nfpm/v2 v2.10.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gosimple/slug v1.9.0 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect
github.com/gostaticanalysis/forcetypeassert v0.0.0-20200621232751-01d4955beaa5 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/hairyhenderson/toml v0.3.1-0.20191004034452-2a4f3b6160f2 // indirect
github.com/hashicorp/consul/api v1.10.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.12.0 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.6.8 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/go-version v1.2.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.9.5 // indirect
github.com/hashicorp/vault/api v1.0.4 // indirect
github.com/hashicorp/vault/sdk v0.1.13 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
Expand All @@ -168,7 +151,6 @@ require (
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/julz/importas v0.0.0-20210419104244-841f0c0fe66d // indirect
github.com/kevinburke/ssh_config v1.1.0 // indirect
Expand Down Expand Up @@ -204,7 +186,6 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349 // indirect
Expand All @@ -213,13 +194,10 @@ require (
github.com/prometheus/common v0.10.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/quasilyte/go-ruleguard v0.3.13 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200805063351-8f842688393c // indirect
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
github.com/rs/zerolog v1.20.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryancurrah/gomodguard v1.2.3 // indirect
github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect
github.com/securego/gosec/v2 v2.9.1 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
Expand All @@ -236,7 +214,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.9.0 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/sylvia7788/contextcheck v1.0.4 // indirect
Expand All @@ -246,7 +224,6 @@ require (
github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94 // indirect
github.com/tomarrell/wrapcheck/v2 v2.4.0 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.4.0 // indirect
github.com/ugorji/go/codec v1.2.3 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/ultraware/funlen v0.0.3 // indirect
github.com/ultraware/whitespace v0.0.4 // indirect
Expand All @@ -255,8 +232,6 @@ require (
github.com/xanzy/go-gitlab v0.50.3 // indirect
github.com/xanzy/ssh-agent v0.3.1 // indirect
github.com/yeya24/promlinter v0.1.0 // indirect
github.com/zealic/xignore v0.3.3 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
go.opencensus.io v0.23.0 // indirect
gocloud.dev v0.24.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
Expand All @@ -278,7 +253,6 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/mail.v2 v2.3.1 // indirect
gopkg.in/square/go-jose.v2 v2.3.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
Expand Down
Loading

0 comments on commit ed330c6

Please sign in to comment.