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
All checks were successful
Test Action / test (push) Successful in 3s
This commit is contained in:
@@ -15,6 +15,10 @@ inputs:
|
||||
description: 'The type of the file to be downloaded (archive, package, or custom regex).'
|
||||
required: false
|
||||
default: 'archive'
|
||||
update-cache:
|
||||
description: 'How to handle the tool cache (false, true, or always). Defaults to false.'
|
||||
required: false
|
||||
default: 'false'
|
||||
debug:
|
||||
description: 'When set to true, displays the contents of the unpacked archive or directory.'
|
||||
required: false
|
||||
|
||||
50
dist/index.js
vendored
50
dist/index.js
vendored
File diff suppressed because one or more lines are too long
25
src/index.ts
25
src/index.ts
@@ -40,6 +40,7 @@ async function run() {
|
||||
let fileName = core.getInput('file-name');
|
||||
const binaryInput = core.getInput('binary-name');
|
||||
const fileType = core.getInput('file-type') || 'archive';
|
||||
const updateCache = core.getInput('update-cache') || 'false';
|
||||
const debug = core.getBooleanInput('debug');
|
||||
const token = core.getInput('token') || process.env.GITHUB_TOKEN;
|
||||
|
||||
@@ -47,6 +48,25 @@ async function run() {
|
||||
const platform = os.platform(); // 'linux', 'darwin', 'win32'
|
||||
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> = {
|
||||
linux: 'linux',
|
||||
darwin: '(darwin|macos|mac)',
|
||||
@@ -141,16 +161,17 @@ async function run() {
|
||||
}
|
||||
|
||||
const version = data.tag_name.replace(/^v/, '');
|
||||
const toolName = repository.split('/').pop() || repository;
|
||||
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)
|
||||
if (updateCache !== 'always') {
|
||||
const cachedDir = tc.find(toolName, version, arch);
|
||||
if (cachedDir) {
|
||||
core.info(`Found ${toolName} version ${version} in cache at ${cachedDir}`);
|
||||
core.addPath(cachedDir);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const downloadUrl = asset.browser_download_url;
|
||||
core.info(`Downloading ${asset.name} from ${downloadUrl}...`);
|
||||
|
||||
Reference in New Issue
Block a user