Skip to content

Commit

Permalink
fixup! Fix interpolation without version
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Dec 2, 2024
1 parent 16e402a commit 6db3e95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 7 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function mkReleaseConfig(
): Promise<ReleaseConfig> {
const {
name,
version,
version: rawVersion,
url: urlTemplate,
subdir: subdirTemplate,
os,
Expand All @@ -59,22 +59,15 @@ async function mkReleaseConfig(
githubTokenForLatest,
} = await getInputs(platform, osArch, core);

const templateVars = { name, version, os, arch, ext };

const interpolateLatest = async (): Promise<string> => {
// 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<string> => {
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;
Expand Down

0 comments on commit 6db3e95

Please sign in to comment.