mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-05-24 09:54:47 +00:00
Fixed reviewed points
Co-authored-by: Kevin Stillhammer <kevin.stillhammer@gmail.com>
This commit is contained in:
parent
db2faa91da
commit
d59153e3d6
3 changed files with 57 additions and 83 deletions
|
@ -71,9 +71,13 @@ export async function downloadVersion(
|
|||
}
|
||||
|
||||
export async function resolveVersion(
|
||||
version: string,
|
||||
versionInput: string,
|
||||
githubToken: string,
|
||||
): Promise<string> {
|
||||
const version =
|
||||
versionInput === "latest"
|
||||
? await getLatestVersion(githubToken)
|
||||
: versionInput;
|
||||
if (tc.isExplicitVersion(version)) {
|
||||
core.debug(`Version ${version} is an explicit version.`);
|
||||
return version;
|
||||
|
@ -95,3 +99,17 @@ async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
|||
});
|
||||
return response.map((release) => release.tag_name);
|
||||
}
|
||||
|
||||
async function getLatestVersion(githubToken: string) {
|
||||
const octokit = github.getOctokit(githubToken);
|
||||
|
||||
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
});
|
||||
|
||||
if (!latestRelease) {
|
||||
throw new Error("Could not determine latest release.");
|
||||
}
|
||||
return latestRelease.tag_name;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue