From 8a360266f3abda6c9ed909a850ae058da1b3a17c Mon Sep 17 00:00:00 2001 From: Akkuman Date: Tue, 9 Dec 2025 11:07:25 +0800 Subject: [PATCH] feat: prioritize tools from cache --- src/goreleaser.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/goreleaser.ts b/src/goreleaser.ts index 6a42a1e..ec5c3b2 100644 --- a/src/goreleaser.ts +++ b/src/goreleaser.ts @@ -2,6 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as util from 'util'; import yaml from 'js-yaml'; +import os from 'os'; import * as context from './context'; import * as github from './github'; import * as core from '@actions/core'; @@ -9,6 +10,13 @@ import * as tc from '@actions/tool-cache'; export async function install(distribution: string, version: string): Promise { const release: github.GitHubRelease = await github.getRelease(distribution, version); + // check cache + const toolDirPath = tc.find('goreleaser-action', release.tag_name.replace(/^v/, ''), os.arch()); + // If not found in cache, download + if (toolDirPath) { + core.info(`Found in cache @ ${toolDirPath}`); + return path.join(toolDirPath, context.osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser'); + } const filename = getFilename(distribution); const downloadUrl = util.format( 'https://github.com/goreleaser/%s/releases/download/%s/%s',