Skip to content

Commit

Permalink
fix: workaround windows install script (#477)
Browse files Browse the repository at this point in the history
Because of a small bug the version of curl presently on GitHub windows runners,
Syft's install.sh file can fail to execute. Therefore, at least for now, fall
back to just using cache.downloadTool to get Syft.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
  • Loading branch information
willmurphyscode authored Jul 9, 2024
1 parent 72370e1 commit 95b086a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
17 changes: 16 additions & 1 deletion dist/attachReleaseAssets/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion dist/downloadSyft/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion dist/runSyftAction/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion src/github/SyftGithubAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,28 @@ async function executeSyft({
}
}

function isWindows(): boolean {
return process.platform == "win32";
}

async function downloadSyftWindowsWorkaround(version: string): Promise<string> {
const versionNoV = version.replace(/^v/, "");
const url = `https://github.com/anchore/syft/releases/download/${version}/syft_${versionNoV}_windows_amd64.zip`;
core.info(`Downloading syft from ${url}`);
const zipPath = await cache.downloadTool(url);
const toolDir = await cache.extractZip(zipPath);
return path.join(toolDir, `${SYFT_BINARY_NAME}${exeSuffix}`);
}

/**
* Downloads the appropriate Syft binary for the platform
*/
export async function downloadSyft(): Promise<string> {
const name = SYFT_BINARY_NAME;
const version = SYFT_VERSION;
if (isWindows()) {
return downloadSyftWindowsWorkaround(version);
}

const url = `https://raw.githubusercontent.com/anchore/${name}/main/install.sh`;

Expand All @@ -211,7 +227,6 @@ export async function downloadSyft(): Promise<string> {
// Download the installer, and run
const installPath = await cache.downloadTool(url);

// Make sure the tool's executable bit is set
const syftBinaryPath = `${installPath}_${name}`;

await execute("sh", [installPath, "-d", "-b", syftBinaryPath, version]);
Expand Down

0 comments on commit 95b086a

Please sign in to comment.