From e49d06518c8cbf091176c4d38df70b1a8862ac12 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Wed, 28 Jun 2023 22:14:43 -0400 Subject: [PATCH] feat: support arch and darwin/linux properly --- src/setup.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/setup.ts b/src/setup.ts index b933ead..571653b 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -63,11 +63,24 @@ async function fetchKubectl(version: string) { return join(cachedPath, 'kubectl') } - // TODO: Support other platforms - const url = `https://dl.k8s.io/release/${version}/bin/linux/amd64/kubectl` + const url = `https://dl.k8s.io/release/${version}/bin/${retrieveRunnerMetadata()}/kubectl` console.log(`Downloading kubectl (${url})`) const downloadPath = await downloadTool(url) const toolPath = await cacheFile(downloadPath, 'kubectl', 'kubectl', version) return join(toolPath, 'kubectl') } + +// Gets the proper architecture and OS for the current platform +// This doesn't use node functions, but instead CI variables provided by GitHub +function retrieveRunnerMetadata() { + // Currently we don't support win32 platforms anyways + const runnerSystem = env.RUNNER_OS === 'Linux' ? 'linux' : 'darwin' + const runnerArch = env.RUNNER_ARCH?.toLowerCase() + + if (runnerArch?.includes('arm')) { + return `${runnerSystem}/arm64` + } + + return `${runnerSystem}/amd64` +}