Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ builds:
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
ldflags:
- -s -w -X github.com/itaysk/kubectl-neat/cmd.Version={{ .Version }}
archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
allow_different_binary_count: true
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,26 @@ dist/kubectl-neat_darwin_arm64.tar.gz dist/kubectl-neat_darwin_amd64.tar.gz dist
@:

release: publish = 1
release: dist/kubectl-neat_darwin_arm64.tar.gz dist/kubectl-neat_darwin_amd64.tar.gz dist/kubectl-neat_linux_arm64.tar.gz dist/kubectl-neat_linux_amd64.tar.gz dist/checksums.txt
release: dist/kubectl-neat_darwin_arm64.tar.gz dist/kubectl-neat_darwin_amd64.tar.gz dist/kubectl-neat_linux_arm64.tar.gz dist/kubectl-neat_linux_amd64.tar.gz dist/kubectl-neat_windows_amd64 dist/checksums.txt
./krew-package.sh 'darwin' 'arm64' 'neat' './dist'
./krew-package.sh 'darwin' 'amd64' 'neat' './dist'
./krew-package.sh 'linux' 'arm64' 'neat' './dist'
./krew-package.sh 'linux' 'amd64' 'neat' './dist'
# merge
yq r --tojson "dist/kubectl-neat_darwin_amd64.yaml" > dist/darwin-amd64.json
yq r --tojson "dist/kubectl-neat_darwin_arm64.yaml" > dist/darwin-arm64.json
yq r --tojson "dist/kubectl-neat_linux_amd64.yaml" > dist/linux-amd64.json
yq r --tojson "dist/kubectl-neat_linux_arm64.yaml" > dist/linux-arm64.json
./krew-package.sh 'windows' 'amd64' 'neat' './dist'

# merge
yq "dist/kubectl-neat_darwin_amd64.yaml" -o=json > dist/darwin-amd64.json
yq "dist/kubectl-neat_darwin_arm64.yaml" -o=json > dist/darwin-arm64.json
yq "dist/kubectl-neat_linux_amd64.yaml" -o=json > dist/linux-amd64.json
yq "dist/kubectl-neat_linux_arm64.yaml" -o=json > dist/linux-arm64.json
yq "dist/kubectl-neat_windows_amd64.yaml" -o=json > dist/windows-amd64.json
rm dist/kubectl-neat_darwin_arm64.yaml dist/kubectl-neat_darwin_amd64.yaml dist/kubectl-neat_linux_arm64.yaml dist/kubectl-neat_linux_amd64.yaml
jq --slurp '.[0].spec.platforms += .[1].spec.platforms | .[0]' 'dist/darwin-amd64.json' 'dist/darwin-arm64.json' > 'dist/darwin.json'
jq --slurp '.[0].spec.platforms += .[1].spec.platforms | .[0]' 'dist/linux-amd64.json' 'dist/linux-arm64.json' > 'dist/linux.json'
jq --slurp '.[0].spec.platforms += .[1].spec.platforms | .[0]' 'dist/linux.json' 'dist/darwin.json' > 'dist/kubectl-neat.json'
yq r --prettyPrint dist/kubectl-neat.json > dist/kubectl-neat.yaml
jq --slurp '.[0].spec.platforms += .[1].spec.platforms | .[0]' 'dist/windows-amd64.json' 'dist/windows-amd64.json' > 'dist/kubectl-neat.json'

yq --prettyPrint dist/kubectl-neat.json > dist/kubectl-neat.yaml
rm dist/kubectl-neat.json dist/darwin.json dist/linux.json dist/darwin-amd64.json dist/darwin-arm64.json dist/linux-amd64.json dist/linux-arm64.json

clean:
Expand Down
5 changes: 2 additions & 3 deletions krew-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
# 2. target arch (`amd64`/`arm64`)
# 2. plugin name (rename the plugin in tests to avoid conflicts with existing installation)
# 3. path to goreleaser dist directory

os="$1"
arch="$2"
plugin="$3"
dir="$4"

sha256=$(grep "${os}_$arch" "$dir/checksums.txt" | cut -f1 -d ' ')
tmp="$dir/kubectl-${plugin}_${os}_${arch}.json"
yq r --tojson krew-template.yaml >"$tmp"
yq krew-template.yaml -o=json >"$tmp"
jq 'delpaths([path(.spec.platforms[] | select( .selector.matchLabels.os != $os or .selector.matchLabels.arch != $arch ))])' --arg os "$os" --arg arch "$arch" "$tmp" | sponge "$tmp"
jq '.metadata.name = $name' --arg name "$plugin" "$tmp" | sponge "$tmp"
jq 'setpath(path(.spec.platforms[] | select( .selector.matchLabels.os == $os and .selector.matchLabels.arch == $arch) | .sha256); $sha)' --arg os "$os" --arg arch "$arch" --arg sha "$sha256" "$tmp" | sponge "$tmp"
yq r --prettyPrint "$tmp" > "${tmp%.json}.yaml"
yq --prettyPrint "$tmp" > "${tmp%.json}.yaml"
rm "$tmp"
9 changes: 8 additions & 1 deletion krew-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Plugin
metadata:
name: neat
spec:
version: "v2.0.3"
version: "v2.0.5"
shortDescription: Remove clutter from Kubernetes manifests to make them more readable.
homepage: https://github.com/itaysk/kubectl-neat
description: |
Expand Down Expand Up @@ -41,4 +41,11 @@ spec:
arch: arm64
uri: https://github.com/itaysk/kubectl-neat/releases/download/v2.0.3/kubectl-neat_linux_arm64.tar.gz
sha256: ${sha256}
bin: "./kubectl-neat"
- selector:
matchLabels:
os: windows
arch: amd64
uri: https://github.com/itaysk/kubectl-neat/releases/download/v2.0.3/kubectl-neat_windows_amd64.exe
sha256: ${sha256}
bin: "./kubectl-neat"