Skip to content

Commit 445689e

Browse files
authored
Use latest version from manifest-file (#458)
If a manifest-file is supplied the default value of the version input (latest) will get the latest version available in the manifest. That might not be the actual latest version available in the official uv repo.
1 parent a02a550 commit 445689e

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ jobs:
540540
- name: Install from custom manifest file
541541
uses: ./
542542
with:
543-
version: 0.7.12-alpha.1
544543
manifest-file: "https://raw.githubusercontent.com/astral-sh/setup-uv/${{ github.ref }}/__tests__/download/custom-manifest.json"
545544
- run: uv sync
546545
working-directory: __tests__/fixtures/uv-project

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ This is useful if you maintain your own uv builds or want to override the defaul
430430
manifest-file: "https://example.com/my-custom-manifest.json"
431431
```
432432

433+
> [!NOTE]
434+
> When you use a custom manifest file and do not set the `version` input, its default value is `latest`.
435+
> This means the action will install the latest version available in the custom manifest file.
436+
> This is different from the default behavior of installing the latest version from the official uv releases.
437+
433438
## How it works
434439

435440
This action downloads uv from the uv repo's official

dist/setup/index.js

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/download/download-version.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
77
import type { Architecture, Platform } from "../utils/platforms";
88
import { validateChecksum } from "./checksum/checksum";
99
import { Octokit } from "../utils/octokit";
10-
import { getDownloadUrl } from "./version-manifest";
10+
import {
11+
getDownloadUrl,
12+
getLatestKnownVersion as getLatestVersionInManifest,
13+
} from "./version-manifest";
1114

1215
export function tryGetFromToolCache(
1316
arch: Architecture,
@@ -127,13 +130,22 @@ function getExtension(platform: Platform): string {
127130

128131
export async function resolveVersion(
129132
versionInput: string,
133+
manifestFile: string | undefined,
130134
githubToken: string,
131135
): Promise<string> {
132136
core.debug(`Resolving version: ${versionInput}`);
133-
const version =
134-
versionInput === "latest"
135-
? await getLatestVersion(githubToken)
136-
: versionInput;
137+
let version: string;
138+
if (manifestFile) {
139+
version =
140+
versionInput === "latest"
141+
? await getLatestVersionInManifest(manifestFile)
142+
: versionInput;
143+
} else {
144+
version =
145+
versionInput === "latest"
146+
? await getLatestVersion(githubToken)
147+
: versionInput;
148+
}
137149
if (tc.isExplicitVersion(version)) {
138150
core.debug(`Version ${version} is an explicit version.`);
139151
return version;

src/setup-uv.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async function setupUv(
8787
checkSum: string | undefined,
8888
githubToken: string,
8989
): Promise<{ uvDir: string; version: string }> {
90-
const resolvedVersion = await determineVersion();
90+
const resolvedVersion = await determineVersion(manifestFile);
9191
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
9292
if (toolCacheResult.installedPath) {
9393
core.info(`Found uv in tool-cache for ${toolCacheResult.version}`);
@@ -127,9 +127,11 @@ async function setupUv(
127127
};
128128
}
129129

130-
async function determineVersion(): Promise<string> {
130+
async function determineVersion(
131+
manifestFile: string | undefined,
132+
): Promise<string> {
131133
if (versionInput !== "") {
132-
return await resolveVersion(versionInput, githubToken);
134+
return await resolveVersion(versionInput, manifestFile, githubToken);
133135
}
134136
const versionFromUvToml = getUvVersionFromConfigFile(
135137
`${workingDirectory}${path.sep}uv.toml`,
@@ -144,6 +146,7 @@ async function determineVersion(): Promise<string> {
144146
}
145147
return await resolveVersion(
146148
versionFromUvToml || versionFromPyproject || "latest",
149+
manifestFile,
147150
githubToken,
148151
);
149152
}

0 commit comments

Comments
 (0)