From 7e0e2322a370353a3b7ebe9fc9bc61c8664eb243 Mon Sep 17 00:00:00 2001 From: Caitlin Schaefer Date: Fri, 10 Jan 2025 12:03:02 -0800 Subject: [PATCH] reference runner arch, not just amd64 always --- dist/index.js | 19 +++++++++++++++++-- src/action.ts | 22 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 69eff9e..712007a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13565,8 +13565,23 @@ function osPlatform() { case "linux": case "darwin": return platform; + case "win32": + return "windows"; default: - throw new Error("Unsupported operating system - the Patcher action is only released for Darwin and Linux"); + throw new Error("Unsupported operating system - the Patcher action is only released for Darwin, Linux, and Windows32."); + } +} +function arch() { + const arch = os.arch(); + switch (arch) { + case "arm64": + return arch; + case "x64": + return "amd64"; + case "ia32": + return "386"; + default: + throw new Error("Unsupported architecture - the Patcher action is only released for arm64, amd64, and i386."); } } function repoToBinaryMap(repo) { @@ -13598,7 +13613,7 @@ async function downloadGitHubBinary(octokit, owner, repo, tag, token) { repo, tag, }); - const re = new RegExp(`${osPlatform()}.*amd64`); + const re = new RegExp(`${osPlatform()}.*${arch()}`); const asset = getReleaseResponse.data.assets.find((obj) => re.test(obj.name)); if (!asset) { throw new Error(`Can not find ${owner}/${repo} release for ${tag} in platform ${re}.`); diff --git a/src/action.ts b/src/action.ts index a4af35f..ad17ce0 100644 --- a/src/action.ts +++ b/src/action.ts @@ -74,8 +74,26 @@ function osPlatform() { case "linux": case "darwin": return platform; + case "win32": + return "windows"; default: - throw new Error("Unsupported operating system - the Patcher action is only released for Darwin and Linux"); + throw new Error( + "Unsupported operating system - the Patcher action is only released for Darwin, Linux, and Windows32." + ); + } +} + +function arch() { + const arch = os.arch(); + switch (arch) { + case "arm64": + return arch; + case "x64": + return "amd64"; + case "ia32": + return "386"; + default: + throw new Error("Unsupported architecture - the Patcher action is only released for arm64, amd64, and i386."); } } @@ -123,7 +141,7 @@ async function downloadGitHubBinary( tag, }); - const re = new RegExp(`${osPlatform()}.*amd64`); + const re = new RegExp(`${osPlatform()}.*${arch()}`); const asset = getReleaseResponse.data.assets.find((obj: any) => re.test(obj.name)); if (!asset) {