Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade external tools #103

Merged
merged 1 commit into from
Jul 12, 2024
Merged
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
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ dist/kubectl-neat_%: $(SRC)
GOOS=$(call underscore,$*,1) GOARCH=$(call underscore,$*,2) go build -o dist/$(@F)

# release by default will not publish. run with `publish=1` to publish
goreleaserflags = --skip-publish --snapshot
goreleaserflags = --skip=publish --snapshot
ifdef publish
goreleaserflags =
endif
# relase always re-builds (no dependencies on purpose)
goreleaser: $(SRC)
goreleaser --rm-dist $(goreleaserflags)
goreleaser --clean $(goreleaserflags)

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: goreleaser
# no op recipe
Expand All @@ -49,16 +49,16 @@ release: dist/kubectl-neat_darwin_arm64.tar.gz dist/kubectl-neat_darwin_amd64.ta
./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
yq -o json "dist/kubectl-neat_darwin_amd64.yaml" > dist/darwin-amd64.json
yq -o json "dist/kubectl-neat_darwin_arm64.yaml" > dist/darwin-arm64.json
yq -o json "dist/kubectl-neat_linux_amd64.yaml" > dist/linux-amd64.json
yq -o json "dist/kubectl-neat_linux_arm64.yaml" > dist/linux-arm64.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
yq -o yaml --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
4 changes: 2 additions & 2 deletions krew-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ 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 -o json krew-template.yaml >"$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 -o yaml --prettyPrint "$tmp" > "${tmp%.json}.yaml"
rm "$tmp"
Loading