From d466ec4b1fb43f2239a3a5323c979519ea2c97e0 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Tue, 11 Jul 2023 14:37:07 -0400 Subject: [PATCH] add the ability to download kind/kubectl on macOS GHA runners Important note - This doesn't setup Docker on MacOS. To setup Docker, you either need to use the Docker Desktop GHA (https://github.com/docker/desktop-action), or you need to connect your MacOS runner to a remote Docker Daemon. Signed-off-by: Nick Santos --- kind.sh | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/kind.sh b/kind.sh index 915d6b7..e61bb92 100755 --- a/kind.sh +++ b/kind.sh @@ -56,14 +56,27 @@ main() { exit 1 fi - local arch - case $(uname -m) in - i386) arch="386" ;; - i686) arch="386" ;; - x86_64) arch="amd64" ;; - arm|aarch64) dpkg --print-architecture | grep -q "arm64" && arch="arm64" || arch="arm" ;; + local os="linux" + case $(uname) in + Darwin) os="darwin" ;; esac - local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${arch}" + + local arch + if [[ "$os" == "darwin" ]]; then + case $(uname -m) in + x86_64) arch="amd64" ;; + arm) arch="arm64" ;; + esac + else + case $(uname -m) in + i386) arch="386" ;; + i686) arch="386" ;; + x86_64) arch="amd64" ;; + arm|aarch64) dpkg --print-architecture | grep -q "arm64" && arch="arm64" || arch="arm" ;; + esac + fi + + local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${os}/${arch}" local kind_dir="${cache_dir}/kind/bin/" if [[ ! -x "${kind_dir}/kind" ]]; then @@ -188,7 +201,7 @@ install_kind() { mkdir -p "${kind_dir}" - curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-linux-${arch}" + curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-${os}-${arch}" chmod +x "${kind_dir}/kind" } @@ -197,7 +210,7 @@ install_kubectl() { mkdir -p "${kubectl_dir}" - curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${arch}/kubectl" + curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/${os}/${arch}/kubectl" chmod +x "${kubectl_dir}/kubectl" }