Skip to content

Commit

Permalink
hack: offer .tar.gz releases, use for posix (kubernetes-sigs#105)
Browse files Browse the repository at this point in the history
- create krew.tar.gz{,.sha256sum}
- use it in krew.yaml for linux/darwin
- use it in README.md for linux/darwin instalation (fixes kubernetes-sigs#101)

Signed-off-by: Ahmet Alp Balkan <[email protected]>
  • Loading branch information
ahmetb authored Oct 14, 2018
1 parent 4826243 commit 9207175
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ For macOS and Linux:
```sh
(
set -x; cd "$(mktemp -d)" &&
curl -fsSLO "https://github.com/GoogleContainerTools/krew/releases/download/v0.2.0/krew.{zip,yaml}" &&
unzip krew.zip &&
curl -fsSLO "https://github.com/GoogleContainerTools/krew/releases/download/v0.2.0/krew.{tar.gz,yaml}" &&
tar zxvf krew.tar.gz &&
./out/bin/krew-"$(uname | tr '[:upper:]' '[:lower:]')_amd64" install \
--manifest=krew.yaml --archive=krew.zip
)
Expand Down
12 changes: 6 additions & 6 deletions hack/krew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ spec:
version: "KREW_TAG"
shortDescription: Package manager for kubectl plugins.
platforms:
- uri: https://github.com/GoogleContainerTools/krew/releases/download/KREW_TAG/krew.zip
sha256: KREW_ZIP_CHECKSUM
- uri: https://github.com/GoogleContainerTools/krew/releases/download/KREW_TAG/krew.tar.gz
sha256: KREW_TAR_CHECKSUM
bin: krew
files:
- from: out/bin/krew-darwin_amd64
Expand All @@ -30,8 +30,8 @@ spec:
matchLabels:
os: darwin
arch: amd64
- uri: https://github.com/GoogleContainerTools/krew/releases/download/KREW_TAG/krew.zip
sha256: KREW_ZIP_CHECKSUM
- uri: https://github.com/GoogleContainerTools/krew/releases/download/KREW_TAG/krew.tar.gz
sha256: KREW_TAR_CHECKSUM
bin: krew
files:
- from: out/bin/krew-linux_amd64
Expand All @@ -40,8 +40,8 @@ spec:
matchLabels:
os: linux
arch: amd64
- uri: https://github.com/GoogleContainerTools/krew/releases/download/KREW_TAG/krew.zip
sha256: KREW_ZIP_CHECKSUM
- uri: https://github.com/GoogleContainerTools/krew/releases/download/KREW_TAG/krew.tar.gz
sha256: KREW_TAR_CHECKSUM
bin: krew
files:
- from: out/bin/krew-linux_arm
Expand Down
29 changes: 21 additions & 8 deletions hack/make-release-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,36 @@ if [[ ! -d "${bin_dir}" ]]; then
exit 1
fi

krew_archive="krew.zip"
echo >&2 "Creating ${krew_archive} archive."
zip -X -q -r --verbose out/krew.zip "${bin_dir}"
krew_tar_archive="krew.tar.gz"
krew_zip_archive="krew.zip"

echo >&2 "Creating ${krew_tar_archive} archive."
tar czvf "out/${krew_tar_archive}" "${bin_dir}"
echo >&2 "Creating ${krew_zip_archive} archive."
zip -X -q -r --verbose "out/${krew_zip_archive}" "${bin_dir}"

checksum_cmd="shasum -a 256"
if hash sha256sum 2>/dev/null; then
checksum_cmd="sha256sum"
fi
zip_checksum="$(eval "${checksum_cmd[@]}" "out/${krew_archive}" | awk '{print $1;}')"
sumfile="out/${krew_archive}.sha256"
echo >&2 "${krew_archive} checksum: ${zip_checksum}"
echo >&2 "${zip_checksum}" > "${sumfile}"
echo >&2 "Written ${sumfile}."

tar_sumfile="out/${krew_tar_archive}.sha256"
tar_checksum="$(eval "${checksum_cmd[@]}" "out/${krew_tar_archive}" | awk '{print $1;}')"
echo >&2 "${krew_tar_archive} checksum: ${tar_checksum}"
echo "${tar_checksum}" > "${tar_sumfile}"
echo >&2 "Written ${tar_sumfile}."

zip_sumfile="out/${krew_zip_archive}.sha256"
zip_checksum="$(eval "${checksum_cmd[@]}" "out/${krew_zip_archive}" | awk '{print $1;}')"
echo >&2 "${krew_zip_archive} checksum: ${zip_checksum}"
echo "${zip_checksum}" > "${zip_sumfile}"
echo >&2 "Written ${zip_sumfile}."


# Copy and process krew manifest
cp ./hack/krew.yaml ./out/krew.yaml
tag="$(git describe --tags --always HEAD)"
sed -i "s/KREW_ZIP_CHECKSUM/${zip_checksum}/g" ./out/krew.yaml
sed -i "s/KREW_TAR_CHECKSUM/${tar_checksum}/g" ./out/krew.yaml
sed -i "s/KREW_TAG/${tag}/g" ./out/krew.yaml
echo >&2 "Written krew.yaml."

0 comments on commit 9207175

Please sign in to comment.