From 02f250693515a6c5d40e15d54e66c7d707b5d4fe Mon Sep 17 00:00:00 2001 From: Yuri Norwood <106889957+norwd@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:53:42 +1300 Subject: [PATCH] Manually setup binpath and add it to system path Signed-off-by: Yuri Norwood <106889957+norwd@users.noreply.github.com> --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9f8ab41..6ad4989 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ async function downloadRelease(octokit, os, org, repo, release, token) { // Determine environment specific details, paths etc... const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`; const tempdir = os === "windows" ? process.env.TEMP + "\\" : "/tmp/"; - const binpath = os === "windows" ? "C:\\Windows\\System32" : "/usr/local/bin"; + const binpath = os === "windows" ? process.env.USERPROFILE + "\\bin" : "/usr/local/bin"; const extract = os === "windows" ? "tar -xvf" : "tar -xvzf"; const archive = `${tempdir}gotestfmt${postfix}`; @@ -32,6 +32,11 @@ async function downloadRelease(octokit, os, org, repo, release, token) { execSync(`curl -L -o ${archive} ${asset.browser_download_url}`) } + // Ensure the that the install target exists + console.log("Preparing install target...") + fs.mkdirSync(binpath, { recursive: true }) + core.addPath(binpath); + // Extract the archive into the install target console.log("Unpacking archive file...") execSync(`cd "${binpath}" && ${extract} ${archive}`)