Update: Added option update-cache, and changed default action behavior to always use cached version without checking for a new one.
All checks were successful
Test Action / test (push) Successful in 3s

This commit is contained in:
2026-01-11 08:05:18 +01:00
parent 03b8e6fa3b
commit ef971a6da4
3 changed files with 57 additions and 32 deletions

View File

@@ -15,6 +15,10 @@ inputs:
description: 'The type of the file to be downloaded (archive, package, or custom regex).' description: 'The type of the file to be downloaded (archive, package, or custom regex).'
required: false required: false
default: 'archive' default: 'archive'
update-cache:
description: 'How to handle the tool cache (false, true, or always). Defaults to false.'
required: false
default: 'false'
debug: debug:
description: 'When set to true, displays the contents of the unpacked archive or directory.' description: 'When set to true, displays the contents of the unpacked archive or directory.'
required: false required: false

50
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -40,6 +40,7 @@ async function run() {
let fileName = core.getInput('file-name'); let fileName = core.getInput('file-name');
const binaryInput = core.getInput('binary-name'); const binaryInput = core.getInput('binary-name');
const fileType = core.getInput('file-type') || 'archive'; const fileType = core.getInput('file-type') || 'archive';
const updateCache = core.getInput('update-cache') || 'false';
const debug = core.getBooleanInput('debug'); const debug = core.getBooleanInput('debug');
const token = core.getInput('token') || process.env.GITHUB_TOKEN; const token = core.getInput('token') || process.env.GITHUB_TOKEN;
@@ -47,6 +48,25 @@ async function run() {
const platform = os.platform(); // 'linux', 'darwin', 'win32' const platform = os.platform(); // 'linux', 'darwin', 'win32'
const arch = os.arch(); // 'x64', 'arm64' const arch = os.arch(); // 'x64', 'arm64'
const toolName = repository.split('/').pop() || repository;
// Rule for update-cache: 'false' means use ANY cached version if available
if (updateCache === 'false') {
const allVersions = tc.findAllVersions(toolName, arch);
if (allVersions.length > 0) {
// Simple sort to pick the 'latest' local version
const latestVersion = allVersions.sort().pop();
if (latestVersion) {
const cachedDir = tc.find(toolName, latestVersion, arch);
if (cachedDir) {
core.info(`Found ${toolName} version ${latestVersion} in local cache (update-cache: false)`);
core.addPath(cachedDir);
return;
}
}
}
}
const systemPatterns: Record<string, string> = { const systemPatterns: Record<string, string> = {
linux: 'linux', linux: 'linux',
darwin: '(darwin|macos|mac)', darwin: '(darwin|macos|mac)',
@@ -141,15 +161,16 @@ async function run() {
} }
const version = data.tag_name.replace(/^v/, ''); const version = data.tag_name.replace(/^v/, '');
const toolName = repository.split('/').pop() || repository;
const binaryName = binaryInput || toolName; const binaryName = binaryInput || toolName;
// Check if the tool is already in the cache // Check if the tool is already in the cache (if not 'always' update)
const cachedDir = tc.find(toolName, version, arch); if (updateCache !== 'always') {
if (cachedDir) { const cachedDir = tc.find(toolName, version, arch);
core.info(`Found ${toolName} version ${version} in cache at ${cachedDir}`); if (cachedDir) {
core.addPath(cachedDir); core.info(`Found ${toolName} version ${version} in cache at ${cachedDir}`);
return; core.addPath(cachedDir);
return;
}
} }
const downloadUrl = asset.browser_download_url; const downloadUrl = asset.browser_download_url;