Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workaround windows install script #477

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading