diff --git a/.goreleaser.yml b/.goreleaser.yml index 331ea7f..86192c4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,6 +5,7 @@ builds: goos: - darwin - linux + - windows goarch: - amd64 - arm64 @@ -12,6 +13,7 @@ builds: - -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: diff --git a/Makefile b/Makefile index e57de91..f869f19 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/krew-package.sh b/krew-package.sh index 3858a60..14b2b8d 100755 --- a/krew-package.sh +++ b/krew-package.sh @@ -6,7 +6,6 @@ # 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" @@ -14,9 +13,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 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" \ No newline at end of file diff --git a/krew-template.yaml b/krew-template.yaml index ea0e505..65f2f31 100644 --- a/krew-template.yaml +++ b/krew-template.yaml @@ -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: | @@ -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" \ No newline at end of file