Skip to content

Commit

Permalink
upgrade external tools
Browse files Browse the repository at this point in the history
  • Loading branch information
itaysk committed Jul 12, 2024
1 parent 107787c commit 37dacc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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"

0 comments on commit 37dacc8

Please sign in to comment.