From 6db3e9525b09064d4c4f30f21a3588aea02665e6 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Mon, 2 Dec 2024 12:01:12 -0500 Subject: [PATCH] fixup! Fix interpolation without version --- src/github.ts | 2 +- src/main.ts | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/github.ts b/src/github.ts index 073ade3..333317c 100644 --- a/src/github.ts +++ b/src/github.ts @@ -79,6 +79,6 @@ export async function getLatestRelease( const version = data.tag_name; // drop the ^v? core.debug(`Latest release: ${JSON.stringify(data)}`); - core.info(`Using version: ${version}`); + core.info(`Using latest release name as version: ${version}`); return version; } diff --git a/src/main.ts b/src/main.ts index 732e79a..14dd699 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,7 +48,7 @@ async function mkReleaseConfig( ): Promise { const { name, - version, + version: rawVersion, url: urlTemplate, subdir: subdirTemplate, os, @@ -59,22 +59,15 @@ async function mkReleaseConfig( githubTokenForLatest, } = await getInputs(platform, osArch, core); - const templateVars = { name, version, os, arch, ext }; - - const interpolateLatest = async (): Promise => { - // Interpolate without version here, to use for finding latest - const url = interpolateUrl({ name, os, arch, ext }); - const latest = await github.getLatestRelease(url, githubTokenForLatest); - return interpolateUrl({ name, version: latest, os, arch, ext }); + const inferVersion = async (): Promise => { + const url = interpolate(urlTemplate, { name, os, arch, ext }); + return await github.getLatestRelease(url, githubTokenForLatest); }; - const interpolateUrl = (vars: object): string => { - return interpolate(urlTemplate, vars); - }; - - const url = - version === "" ? await interpolateLatest() : interpolateUrl(templateVars); + const version = rawVersion === "" ? await inferVersion() : rawVersion; + const templateVars = { name, version, os, arch, ext }; + const url = interpolate(urlTemplate, templateVars); const subdir = subdirTemplate ? interpolate(subdirTemplate, templateVars) : null;