Update: Added support for tools in a subdirectory.
Some checks failed
Test Action / test (push) Failing after 4s
Some checks failed
Test Action / test (push) Failing after 4s
This commit is contained in:
46
dist/index.js
vendored
46
dist/index.js
vendored
File diff suppressed because one or more lines are too long
20
src/index.ts
20
src/index.ts
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user