Skip to content

Commit 36ec466

Browse files
committed
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 <nick.santos@docker.com>
1 parent 8300bd0 commit 36ec466

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

.github/workflows/test.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ jobs:
6868
- name: Test kind works and there is no cluster started
6969
run: |
7070
[[ $(kind get clusters | wc -l) -eq 0 ]]
71+
72+
test-with-macos-install-only:
73+
runs-on: macos-latest
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
77+
78+
- name: Only install kind without starting a cluster
79+
uses: ./
80+
with:
81+
install_only: true
82+
83+
- name: Test kind works and there is no cluster started
84+
run: |
85+
[[ $(kind get clusters | wc -l) -eq 0 ]]
7186
7287
test-with-custom-kubectl-version:
7388
runs-on: ubuntu-latest

kind.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,27 @@ main() {
5656
exit 1
5757
fi
5858

59-
local arch
60-
case $(uname -m) in
61-
i386) arch="386" ;;
62-
i686) arch="386" ;;
63-
x86_64) arch="amd64" ;;
64-
arm|aarch64|arm64) arch="arm64" ;;
59+
local os="linux"
60+
case $(uname) in
61+
Darwin) os="darwin" ;;
6562
esac
66-
local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${arch}"
63+
64+
local arch
65+
if [[ "$os" == "darwin" ]]; then
66+
case $(uname -m) in
67+
x86_64) arch="amd64" ;;
68+
arm|arm64) arch="arm64" ;;
69+
esac
70+
else
71+
case $(uname -m) in
72+
i386) arch="386" ;;
73+
i686) arch="386" ;;
74+
x86_64) arch="amd64" ;;
75+
arm|aarch64|arm64) arch="arm64" ;;
76+
esac
77+
fi
78+
79+
local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${os}/${arch}"
6780

6881
local kind_dir="${cache_dir}/kind/bin/"
6982
if [[ ! -x "${kind_dir}/kind" ]]; then
@@ -188,7 +201,7 @@ install_kind() {
188201

189202
mkdir -p "${kind_dir}"
190203

191-
curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-linux-${arch}"
204+
curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-${os}-${arch}"
192205
chmod +x "${kind_dir}/kind"
193206
}
194207

@@ -197,7 +210,7 @@ install_kubectl() {
197210

198211
mkdir -p "${kubectl_dir}"
199212

200-
curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${arch}/kubectl"
213+
curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/${os}/${arch}/kubectl"
201214
chmod +x "${kubectl_dir}/kubectl"
202215
}
203216

0 commit comments

Comments
 (0)