feat: use cached binary if present

This commit is contained in:
timbretimber 2025-10-08 05:27:58 -06:00
parent 9cf36111e7
commit d9b8ef613e
4 changed files with 18 additions and 5 deletions

6
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

View file

@ -17,6 +17,19 @@ export async function install(distribution: string, version: string): Promise<st
filename
);
const toolPath: string = tc.find('goreleaser-action', release.tag_name.replace(/^v/, ''), context.osArch);
if (toolPath) {
core.info(`Found in cache @ ${toolPath}`);
const exePath: string = path.join(toolPath, context.osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
try {
// return path only after confirming it exists and is executable
await fs.promises.access(exePath, fs.constants.F_OK | fs.constants.X_OK)
return exePath;
} catch (err) {
core.warning(`Cached tool directory found but executable is not accessible or not executable: ${err.message}`);
}
}
core.info(`Downloading ${downloadUrl}`);
const downloadPath: string = await tc.downloadTool(downloadUrl);
core.debug(`Downloaded to ${downloadPath}`);