Update: Added support for tools in a subdirectory.
Some checks failed
Test Action / test (push) Failing after 4s

This commit is contained in:
2026-01-11 01:04:57 +01:00
parent ba2e6e7dee
commit dd0b70853b
2 changed files with 38 additions and 28 deletions

46
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -124,16 +124,17 @@ async function run() {
const downloadPath = await tc.downloadTool(downloadUrl); const downloadPath = await tc.downloadTool(downloadUrl);
let toolDir: string;
const nameLower = asset.name.toLowerCase(); const nameLower = asset.name.toLowerCase();
let toolDir: string;
if (nameLower.endsWith('.tar.gz') || nameLower.endsWith('.tar') || nameLower.endsWith('.tgz')) { // Determine extraction method based on extension
if (/\.(tar\.gz|tar|tgz)$/i.test(nameLower)) {
toolDir = await tc.extractTar(downloadPath); toolDir = await tc.extractTar(downloadPath);
} else if (nameLower.endsWith('.zip')) { } else if (/\.zip$/i.test(nameLower)) {
toolDir = await tc.extractZip(downloadPath); toolDir = await tc.extractZip(downloadPath);
} else if (nameLower.endsWith('.7z')) { } else if (/\.7z$/i.test(nameLower)) {
toolDir = await tc.extract7z(downloadPath); toolDir = await tc.extract7z(downloadPath);
} else if (nameLower.endsWith('.xar') || nameLower.endsWith('.pkg')) { } else if (/\.(xar|pkg)$/i.test(nameLower)) {
toolDir = await tc.extractXar(downloadPath); toolDir = await tc.extractXar(downloadPath);
} else { } else {
// Treat as a direct binary or non-extractable file // Treat as a direct binary or non-extractable file
@@ -151,6 +152,15 @@ async function run() {
} }
} }
// Handle nested directories in archives
if (/\.(zip|tar(\.gz)?|tgz|7z)$/i.test(nameLower)) {
const items = fs.readdirSync(toolDir);
if (items.length === 1 && fs.statSync(path.join(toolDir, items[0])).isDirectory()) {
core.info(`Detected single root directory in archive, descending into: ${items[0]}`);
toolDir = path.join(toolDir, items[0]);
}
}
core.info(`Tool extracted/located at ${toolDir}`); core.info(`Tool extracted/located at ${toolDir}`);
// Cache the tool // Cache the tool