Compare commits

...

6 Commits

Author SHA1 Message Date
dependabot[bot]
6dcaa740b7 chore(deps): bump release-drafter/release-drafter from 6.2.0 to 7.1.1
Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 6.2.0 to 7.1.1.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](6db134d15f...139054aeaa)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-version: 7.1.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-26 10:53:43 +00:00
github-actions[bot]
5c62c59261 chore: update known checksums for 0.11.1 (#817)
chore: update known checksums for 0.11.1

Co-authored-by: eifinger <eifinger@users.noreply.github.com>
2026-03-25 08:14:06 +01:00
github-actions[bot]
e1a7373adb chore: update known checksums for 0.11.0 (#815)
chore: update known checksums for 0.11.0

Co-authored-by: eifinger <eifinger@users.noreply.github.com>
2026-03-24 07:42:01 +01:00
Kevin Stillhammer
89709315bb Remove deprecrated custom manifest (#813) 2026-03-23 09:15:51 +01:00
Kevin Stillhammer
8cc8d1cbfc Fix latest-version workflow check (#812)
## Summary
- make the latest-version workflow test use the action output for the
exact installed version
- allow `uv --version` to include additional platform/build metadata
- keep validating that the reported version matches the latest GitHub
release

## Testing
- npm ci --ignore-scripts
- npm run all
- actionlint .github/workflows/test.yml

Fixes the failure in
https://github.com/astral-sh/setup-uv/actions/runs/23332230171/job/67866051063
2026-03-20 10:51:55 +01:00
github-actions[bot]
c20049fc26 chore: update known checksums for 0.10.11/0.10.12 (#811) 2026-03-20 07:48:09 +01:00
22 changed files with 1028 additions and 1340 deletions

View File

@@ -19,6 +19,6 @@ jobs:
pull-requests: read pull-requests: read
steps: steps:
- name: 🚀 Run Release Drafter - name: 🚀 Run Release Drafter
uses: release-drafter/release-drafter@6db134d15f3909ccc9eefd369f02bd1e9cffdf97 # v6.2.0 uses: release-drafter/release-drafter@139054aeaa9adc52ab36ddf67437541f039b88e2 # v7.1.1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -164,10 +164,22 @@ jobs:
- name: Latest version gets installed - name: Latest version gets installed
run: | run: |
LATEST_VERSION=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/astral-sh/uv/releases/latest | jq -r '.tag_name') LATEST_VERSION=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/astral-sh/uv/releases/latest | jq -r '.tag_name')
UV_VERSION_OUTPUT=$(uv --version)
if [[ ! "$UV_VERSION_OUTPUT" =~ ^uv[[:space:]]+([^[:space:]]+) ]]; then
echo "Could not parse uv version from: $UV_VERSION_OUTPUT"
exit 1
fi
UV_VERSION="${BASH_REMATCH[1]}"
echo "Latest version is $LATEST_VERSION" echo "Latest version is $LATEST_VERSION"
if [ "$(uv --version)" != "uv $LATEST_VERSION" ]; then echo "uv --version output is $UV_VERSION_OUTPUT"
echo "Wrong uv version: $(uv --version)" echo "Parsed uv version is $UV_VERSION"
exit 1
if [ "$UV_VERSION" != "$LATEST_VERSION" ]; then
echo "Wrong uv version: $UV_VERSION_OUTPUT"
exit 1
fi fi
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
@@ -796,12 +808,12 @@ jobs:
- name: Install from custom manifest file - name: Install from custom manifest file
uses: ./ uses: ./
with: with:
manifest-file: "https://raw.githubusercontent.com/astral-sh/setup-uv/${{ github.ref }}/__tests__/download/custom-manifest.json" manifest-file: "https://raw.githubusercontent.com/astral-sh/setup-uv/${{ github.ref }}/__tests__/download/custom-manifest.ndjson"
- run: uv sync - run: uv sync
working-directory: __tests__/fixtures/uv-project working-directory: __tests__/fixtures/uv-project
- name: Correct version gets installed - name: Correct version gets installed
run: | run: |
if [ "$(uv --version)" != "uv 0.7.12-alpha.1" ]; then if [ "$(uv --version)" != "uv 0.9.26" ]; then
echo "Wrong uv version: $(uv --version)" echo "Wrong uv version: $(uv --version)"
exit 1 exit 1
fi fi

View File

@@ -114,7 +114,7 @@ Have a look under [Advanced Configuration](#advanced-configuration) for detailed
# Custom path to set UV_TOOL_BIN_DIR to # Custom path to set UV_TOOL_BIN_DIR to
tool-bin-dir: "" tool-bin-dir: ""
# URL to a custom manifest file (NDJSON preferred, legacy JSON array is deprecated) # URL to a custom manifest file in the astral-sh/versions format
manifest-file: "" manifest-file: ""
# Add problem matchers # Add problem matchers
@@ -190,8 +190,8 @@ For more advanced configuration options, see our detailed documentation:
## How it works ## How it works
By default, this action resolves uv versions from By default, this action resolves uv versions from the
[`astral-sh/versions`](https://github.com/astral-sh/versions) (NDJSON) and downloads uv from the [`astral-sh/versions`](https://github.com/astral-sh/versions) manifest and downloads uv from the
official [GitHub Releases](https://github.com/astral-sh/uv). official [GitHub Releases](https://github.com/astral-sh/uv).
It then uses the [GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache uv as a It then uses the [GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache uv as a

View File

@@ -1,9 +0,0 @@
[
{
"arch": "x86_64",
"artifactName": "uv-x86_64-unknown-linux-gnu.tar.gz",
"downloadUrl": "https://release.pyx.dev/0.7.12-alpha.1/uv-x86_64-unknown-linux-gnu.tar.gz",
"platform": "unknown-linux-gnu",
"version": "0.7.12-alpha.1"
}
]

View File

@@ -0,0 +1 @@
{"version":"0.9.26","artifacts":[{"platform":"x86_64-unknown-linux-gnu","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz","archive_format":"tar.gz","sha256":"30ccbf0a66dc8727a02b0e245c583ee970bdafecf3a443c1686e1b30ec4939e8"}]}

View File

@@ -32,29 +32,16 @@ jest.unstable_mockModule("@actions/tool-cache", () => ({
})); }));
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetLatestVersionFromNdjson = jest.fn<any>(); const mockGetLatestVersion = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetAllVersionsFromNdjson = jest.fn<any>(); const mockGetAllVersions = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetArtifactFromNdjson = jest.fn<any>(); const mockGetArtifact = jest.fn<any>();
jest.unstable_mockModule("../../src/download/versions-client", () => ({ jest.unstable_mockModule("../../src/download/manifest", () => ({
getAllVersions: mockGetAllVersionsFromNdjson, getAllVersions: mockGetAllVersions,
getArtifact: mockGetArtifactFromNdjson, getArtifact: mockGetArtifact,
getLatestVersion: mockGetLatestVersionFromNdjson, getLatestVersion: mockGetLatestVersion,
}));
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetAllManifestVersions = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetLatestVersionInManifest = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetManifestArtifact = jest.fn<any>();
jest.unstable_mockModule("../../src/download/version-manifest", () => ({
getAllVersions: mockGetAllManifestVersions,
getLatestKnownVersion: mockGetLatestVersionInManifest,
getManifestArtifact: mockGetManifestArtifact,
})); }));
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
@@ -64,12 +51,9 @@ jest.unstable_mockModule("../../src/download/checksum/checksum", () => ({
validateChecksum: mockValidateChecksum, validateChecksum: mockValidateChecksum,
})); }));
const { const { downloadVersion, resolveVersion, rewriteToMirror } = await import(
downloadVersionFromManifest, "../../src/download/download-version"
downloadVersionFromNdjson, );
resolveVersion,
rewriteToMirror,
} = await import("../../src/download/download-version");
describe("download-version", () => { describe("download-version", () => {
beforeEach(() => { beforeEach(() => {
@@ -79,12 +63,9 @@ describe("download-version", () => {
mockExtractTar.mockReset(); mockExtractTar.mockReset();
mockExtractZip.mockReset(); mockExtractZip.mockReset();
mockCacheDir.mockReset(); mockCacheDir.mockReset();
mockGetLatestVersionFromNdjson.mockReset(); mockGetLatestVersion.mockReset();
mockGetAllVersionsFromNdjson.mockReset(); mockGetAllVersions.mockReset();
mockGetArtifactFromNdjson.mockReset(); mockGetArtifact.mockReset();
mockGetAllManifestVersions.mockReset();
mockGetLatestVersionInManifest.mockReset();
mockGetManifestArtifact.mockReset();
mockValidateChecksum.mockReset(); mockValidateChecksum.mockReset();
mockDownloadTool.mockResolvedValue("/tmp/downloaded"); mockDownloadTool.mockResolvedValue("/tmp/downloaded");
@@ -94,36 +75,28 @@ describe("download-version", () => {
}); });
describe("resolveVersion", () => { describe("resolveVersion", () => {
it("uses astral-sh/versions to resolve latest", async () => { it("uses the default manifest to resolve latest", async () => {
mockGetLatestVersionFromNdjson.mockResolvedValue("0.9.26"); mockGetLatestVersion.mockResolvedValue("0.9.26");
const version = await resolveVersion("latest", undefined); const version = await resolveVersion("latest", undefined);
expect(version).toBe("0.9.26"); expect(version).toBe("0.9.26");
expect(mockGetLatestVersionFromNdjson).toHaveBeenCalledTimes(1); expect(mockGetLatestVersion).toHaveBeenCalledTimes(1);
expect(mockGetLatestVersion).toHaveBeenCalledWith(undefined);
}); });
it("uses astral-sh/versions to resolve available versions", async () => { it("uses the default manifest to resolve available versions", async () => {
mockGetAllVersionsFromNdjson.mockResolvedValue(["0.9.26", "0.9.25"]); mockGetAllVersions.mockResolvedValue(["0.9.26", "0.9.25"]);
const version = await resolveVersion("^0.9.0", undefined); const version = await resolveVersion("^0.9.0", undefined);
expect(version).toBe("0.9.26"); expect(version).toBe("0.9.26");
expect(mockGetAllVersionsFromNdjson).toHaveBeenCalledTimes(1); expect(mockGetAllVersions).toHaveBeenCalledTimes(1);
}); expect(mockGetAllVersions).toHaveBeenCalledWith(undefined);
it("does not fall back when astral-sh/versions fails", async () => {
mockGetLatestVersionFromNdjson.mockRejectedValue(
new Error("NDJSON unavailable"),
);
await expect(resolveVersion("latest", undefined)).rejects.toThrow(
"NDJSON unavailable",
);
}); });
it("uses manifest-file when provided", async () => { it("uses manifest-file when provided", async () => {
mockGetAllManifestVersions.mockResolvedValue(["0.9.26", "0.9.25"]); mockGetAllVersions.mockResolvedValue(["0.9.26", "0.9.25"]);
const version = await resolveVersion( const version = await resolveVersion(
"^0.9.0", "^0.9.0",
@@ -131,37 +104,35 @@ describe("download-version", () => {
); );
expect(version).toBe("0.9.26"); expect(version).toBe("0.9.26");
expect(mockGetAllManifestVersions).toHaveBeenCalledWith( expect(mockGetAllVersions).toHaveBeenCalledWith(
"https://example.com/custom.ndjson", "https://example.com/custom.ndjson",
); );
}); });
}); });
describe("downloadVersionFromNdjson", () => { describe("downloadVersion", () => {
it("fails when NDJSON metadata lookup fails", async () => { it("fails when manifest lookup fails", async () => {
mockGetArtifactFromNdjson.mockRejectedValue( mockGetArtifact.mockRejectedValue(new Error("manifest unavailable"));
new Error("NDJSON unavailable"),
);
await expect( await expect(
downloadVersionFromNdjson( downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
undefined, undefined,
"token", "token",
), ),
).rejects.toThrow("NDJSON unavailable"); ).rejects.toThrow("manifest unavailable");
expect(mockDownloadTool).not.toHaveBeenCalled(); expect(mockDownloadTool).not.toHaveBeenCalled();
expect(mockValidateChecksum).not.toHaveBeenCalled(); expect(mockValidateChecksum).not.toHaveBeenCalled();
}); });
it("fails when no matching artifact exists in NDJSON metadata", async () => { it("fails when no matching artifact exists in the default manifest", async () => {
mockGetArtifactFromNdjson.mockResolvedValue(undefined); mockGetArtifact.mockResolvedValue(undefined);
await expect( await expect(
downloadVersionFromNdjson( downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
@@ -176,14 +147,14 @@ describe("download-version", () => {
expect(mockValidateChecksum).not.toHaveBeenCalled(); expect(mockValidateChecksum).not.toHaveBeenCalled();
}); });
it("uses built-in checksums for default NDJSON downloads", async () => { it("uses built-in checksums for default manifest downloads", async () => {
mockGetArtifactFromNdjson.mockResolvedValue({ mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz", archiveFormat: "tar.gz",
sha256: "ndjson-checksum-that-should-be-ignored", checksum: "manifest-checksum-that-should-be-ignored",
url: "https://example.com/uv.tar.gz", downloadUrl: "https://example.com/uv.tar.gz",
}); });
await downloadVersionFromNdjson( await downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
@@ -201,13 +172,14 @@ describe("download-version", () => {
}); });
it("rewrites GitHub Releases URLs to the Astral mirror", async () => { it("rewrites GitHub Releases URLs to the Astral mirror", async () => {
mockGetArtifactFromNdjson.mockResolvedValue({ mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz", archiveFormat: "tar.gz",
sha256: "abc123", checksum: "abc123",
url: "https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz", downloadUrl:
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz",
}); });
await downloadVersionFromNdjson( await downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
@@ -223,13 +195,13 @@ describe("download-version", () => {
}); });
it("does not rewrite non-GitHub URLs", async () => { it("does not rewrite non-GitHub URLs", async () => {
mockGetArtifactFromNdjson.mockResolvedValue({ mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz", archiveFormat: "tar.gz",
sha256: "abc123", checksum: "abc123",
url: "https://example.com/uv.tar.gz", downloadUrl: "https://example.com/uv.tar.gz",
}); });
await downloadVersionFromNdjson( await downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
@@ -245,17 +217,18 @@ describe("download-version", () => {
}); });
it("falls back to GitHub Releases when the mirror fails", async () => { it("falls back to GitHub Releases when the mirror fails", async () => {
mockGetArtifactFromNdjson.mockResolvedValue({ mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz", archiveFormat: "tar.gz",
sha256: "abc123", checksum: "abc123",
url: "https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz", downloadUrl:
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz",
}); });
mockDownloadTool mockDownloadTool
.mockRejectedValueOnce(new Error("mirror unavailable")) .mockRejectedValueOnce(new Error("mirror unavailable"))
.mockResolvedValueOnce("/tmp/downloaded"); .mockResolvedValueOnce("/tmp/downloaded");
await downloadVersionFromNdjson( await downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
@@ -264,14 +237,12 @@ describe("download-version", () => {
); );
expect(mockDownloadTool).toHaveBeenCalledTimes(2); expect(mockDownloadTool).toHaveBeenCalledTimes(2);
// Mirror request: no token
expect(mockDownloadTool).toHaveBeenNthCalledWith( expect(mockDownloadTool).toHaveBeenNthCalledWith(
1, 1,
"https://releases.astral.sh/github/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz", "https://releases.astral.sh/github/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz",
undefined, undefined,
undefined, undefined,
); );
// GitHub fallback: token restored
expect(mockDownloadTool).toHaveBeenNthCalledWith( expect(mockDownloadTool).toHaveBeenNthCalledWith(
2, 2,
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz", "https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz",
@@ -284,16 +255,16 @@ describe("download-version", () => {
}); });
it("does not fall back for non-GitHub URLs", async () => { it("does not fall back for non-GitHub URLs", async () => {
mockGetArtifactFromNdjson.mockResolvedValue({ mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz", archiveFormat: "tar.gz",
sha256: "abc123", checksum: "abc123",
url: "https://example.com/uv.tar.gz", downloadUrl: "https://example.com/uv.tar.gz",
}); });
mockDownloadTool.mockRejectedValue(new Error("download failed")); mockDownloadTool.mockRejectedValue(new Error("download failed"));
await expect( await expect(
downloadVersionFromNdjson( downloadVersion(
"unknown-linux-gnu", "unknown-linux-gnu",
"x86_64", "x86_64",
"0.9.26", "0.9.26",
@@ -304,6 +275,56 @@ describe("download-version", () => {
expect(mockDownloadTool).toHaveBeenCalledTimes(1); expect(mockDownloadTool).toHaveBeenCalledTimes(1);
}); });
it("uses manifest-file checksum metadata when checksum input is unset", async () => {
mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz",
checksum: "manifest-checksum",
downloadUrl: "https://example.com/custom-uv.tar.gz",
});
await downloadVersion(
"unknown-linux-gnu",
"x86_64",
"0.9.26",
"",
"token",
"https://example.com/custom.ndjson",
);
expect(mockValidateChecksum).toHaveBeenCalledWith(
"manifest-checksum",
"/tmp/downloaded",
"x86_64",
"unknown-linux-gnu",
"0.9.26",
);
});
it("prefers checksum input over manifest-file checksum metadata", async () => {
mockGetArtifact.mockResolvedValue({
archiveFormat: "tar.gz",
checksum: "manifest-checksum",
downloadUrl: "https://example.com/custom-uv.tar.gz",
});
await downloadVersion(
"unknown-linux-gnu",
"x86_64",
"0.9.26",
"user-checksum",
"token",
"https://example.com/custom.ndjson",
);
expect(mockValidateChecksum).toHaveBeenCalledWith(
"user-checksum",
"/tmp/downloaded",
"x86_64",
"unknown-linux-gnu",
"0.9.26",
);
});
}); });
describe("rewriteToMirror", () => { describe("rewriteToMirror", () => {
@@ -329,56 +350,4 @@ describe("download-version", () => {
).toBeUndefined(); ).toBeUndefined();
}); });
}); });
describe("downloadVersionFromManifest", () => {
it("uses manifest-file checksum metadata when checksum input is unset", async () => {
mockGetManifestArtifact.mockResolvedValue({
archiveFormat: "tar.gz",
checksum: "manifest-checksum",
downloadUrl: "https://example.com/custom-uv.tar.gz",
});
await downloadVersionFromManifest(
"https://example.com/custom.ndjson",
"unknown-linux-gnu",
"x86_64",
"0.9.26",
"",
"token",
);
expect(mockValidateChecksum).toHaveBeenCalledWith(
"manifest-checksum",
"/tmp/downloaded",
"x86_64",
"unknown-linux-gnu",
"0.9.26",
);
});
it("prefers checksum input over manifest-file checksum metadata", async () => {
mockGetManifestArtifact.mockResolvedValue({
archiveFormat: "tar.gz",
checksum: "manifest-checksum",
downloadUrl: "https://example.com/custom-uv.tar.gz",
});
await downloadVersionFromManifest(
"https://example.com/custom.ndjson",
"unknown-linux-gnu",
"x86_64",
"0.9.26",
"user-checksum",
"token",
);
expect(mockValidateChecksum).toHaveBeenCalledWith(
"user-checksum",
"/tmp/downloaded",
"x86_64",
"unknown-linux-gnu",
"0.9.26",
);
});
});
}); });

View File

@@ -0,0 +1,168 @@
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockFetch = jest.fn<any>();
jest.unstable_mockModule("@actions/core", () => ({
debug: jest.fn(),
info: jest.fn(),
}));
jest.unstable_mockModule("../../src/utils/fetch", () => ({
fetch: mockFetch,
}));
const {
clearManifestCache,
fetchManifest,
getAllVersions,
getArtifact,
getLatestVersion,
parseManifest,
} = await import("../../src/download/manifest");
const sampleManifestResponse = `{"version":"0.9.25","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.25/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"606b3c6949d971709f2526fa0d9f0fd23ccf60e09f117999b406b424af18a6a6"}]}
{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f"},{"platform":"x86_64-pc-windows-msvc","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip","archive_format":"zip","sha256":"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036"}]}`;
const multiVariantManifestResponse = `{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"python-managed","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin-managed.tar.gz","archive_format":"tar.gz","sha256":"managed-checksum"},{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.zip","archive_format":"zip","sha256":"default-checksum"}]}`;
function createMockResponse(
ok: boolean,
status: number,
statusText: string,
data: string,
) {
return {
ok,
status,
statusText,
text: async () => data,
};
}
describe("manifest", () => {
beforeEach(() => {
clearManifestCache();
mockFetch.mockReset();
});
describe("fetchManifest", () => {
it("fetches and parses manifest data", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleManifestResponse),
);
const versions = await fetchManifest();
expect(versions).toHaveLength(2);
expect(versions[0]?.version).toBe("0.9.25");
expect(versions[1]?.version).toBe("0.9.26");
});
it("throws on a failed fetch", async () => {
mockFetch.mockResolvedValue(
createMockResponse(false, 500, "Internal Server Error", ""),
);
await expect(fetchManifest()).rejects.toThrow(
"Failed to fetch manifest data: 500 Internal Server Error",
);
});
it("caches results per URL", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleManifestResponse),
);
await fetchManifest("https://example.com/custom.ndjson");
await fetchManifest("https://example.com/custom.ndjson");
expect(mockFetch).toHaveBeenCalledTimes(1);
});
});
describe("getAllVersions", () => {
it("returns all version strings", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleManifestResponse),
);
const versions = await getAllVersions(
"https://example.com/custom.ndjson",
);
expect(versions).toEqual(["0.9.25", "0.9.26"]);
});
});
describe("getArtifact", () => {
beforeEach(() => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleManifestResponse),
);
});
it("finds an artifact by version and platform", async () => {
const artifact = await getArtifact("0.9.26", "aarch64", "apple-darwin");
expect(artifact).toEqual({
archiveFormat: "tar.gz",
checksum:
"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f",
downloadUrl:
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz",
});
});
it("finds a windows artifact", async () => {
const artifact = await getArtifact("0.9.26", "x86_64", "pc-windows-msvc");
expect(artifact).toEqual({
archiveFormat: "zip",
checksum:
"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036",
downloadUrl:
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip",
});
});
it("prefers the default variant when multiple artifacts share a platform", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", multiVariantManifestResponse),
);
const artifact = await getArtifact("0.9.26", "aarch64", "apple-darwin");
expect(artifact).toEqual({
archiveFormat: "zip",
checksum: "default-checksum",
downloadUrl:
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.zip",
});
});
it("returns undefined for an unknown version", async () => {
const artifact = await getArtifact("0.0.1", "aarch64", "apple-darwin");
expect(artifact).toBeUndefined();
});
it("returns undefined for an unknown platform", async () => {
const artifact = await getArtifact(
"0.9.26",
"aarch64",
"unknown-linux-musl",
);
expect(artifact).toBeUndefined();
});
});
describe("parseManifest", () => {
it("throws for malformed manifest data", () => {
expect(() => parseManifest('{"version":"0.1.0"', "test-source")).toThrow(
"Failed to parse manifest data from test-source",
);
});
});
});

View File

@@ -1,136 +0,0 @@
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
const mockWarning = jest.fn();
jest.unstable_mockModule("@actions/core", () => ({
debug: jest.fn(),
info: jest.fn(),
warning: mockWarning,
}));
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockFetch = jest.fn<any>();
jest.unstable_mockModule("../../src/utils/fetch", () => ({
fetch: mockFetch,
}));
const {
clearManifestCache,
getAllVersions,
getLatestKnownVersion,
getManifestArtifact,
} = await import("../../src/download/version-manifest");
const legacyManifestResponse = JSON.stringify([
{
arch: "x86_64",
artifactName: "uv-x86_64-unknown-linux-gnu.tar.gz",
downloadUrl:
"https://example.com/releases/download/0.7.12-alpha.1/uv-x86_64-unknown-linux-gnu.tar.gz",
platform: "unknown-linux-gnu",
version: "0.7.12-alpha.1",
},
{
arch: "x86_64",
artifactName: "uv-x86_64-unknown-linux-gnu.tar.gz",
downloadUrl:
"https://example.com/releases/download/0.7.13/uv-x86_64-unknown-linux-gnu.tar.gz",
platform: "unknown-linux-gnu",
version: "0.7.13",
},
]);
const ndjsonManifestResponse = `{"version":"0.10.0","artifacts":[{"platform":"x86_64-unknown-linux-gnu","variant":"default","url":"https://example.com/releases/download/0.10.0/uv-x86_64-unknown-linux-gnu.tar.gz","archive_format":"tar.gz","sha256":"checksum-100"}]}
{"version":"0.9.30","artifacts":[{"platform":"x86_64-unknown-linux-gnu","variant":"default","url":"https://example.com/releases/download/0.9.30/uv-x86_64-unknown-linux-gnu.tar.gz","archive_format":"tar.gz","sha256":"checksum-0930"}]}`;
const multiVariantManifestResponse = `{"version":"0.10.0","artifacts":[{"platform":"x86_64-unknown-linux-gnu","variant":"managed-python","url":"https://example.com/releases/download/0.10.0/uv-x86_64-unknown-linux-gnu-managed-python.tar.gz","archive_format":"tar.gz","sha256":"checksum-managed"},{"platform":"x86_64-unknown-linux-gnu","variant":"default","url":"https://example.com/releases/download/0.10.0/uv-x86_64-unknown-linux-gnu-default.zip","archive_format":"zip","sha256":"checksum-default"}]}`;
function createMockResponse(
ok: boolean,
status: number,
statusText: string,
data: string,
) {
return {
ok,
status,
statusText,
text: async () => data,
};
}
describe("version-manifest", () => {
beforeEach(() => {
clearManifestCache();
mockFetch.mockReset();
mockWarning.mockReset();
});
it("supports the legacy JSON manifest format", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", legacyManifestResponse),
);
const latest = await getLatestKnownVersion(
"https://example.com/legacy.json",
);
const artifact = await getManifestArtifact(
"https://example.com/legacy.json",
"0.7.13",
"x86_64",
"unknown-linux-gnu",
);
expect(latest).toBe("0.7.13");
expect(artifact).toEqual({
archiveFormat: undefined,
checksum: undefined,
downloadUrl:
"https://example.com/releases/download/0.7.13/uv-x86_64-unknown-linux-gnu.tar.gz",
});
expect(mockWarning).toHaveBeenCalledTimes(1);
});
it("supports NDJSON manifests", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", ndjsonManifestResponse),
);
const versions = await getAllVersions("https://example.com/custom.ndjson");
const artifact = await getManifestArtifact(
"https://example.com/custom.ndjson",
"0.10.0",
"x86_64",
"unknown-linux-gnu",
);
expect(versions).toEqual(["0.10.0", "0.9.30"]);
expect(artifact).toEqual({
archiveFormat: "tar.gz",
checksum: "checksum-100",
downloadUrl:
"https://example.com/releases/download/0.10.0/uv-x86_64-unknown-linux-gnu.tar.gz",
});
expect(mockWarning).not.toHaveBeenCalled();
});
it("prefers the default variant when a manifest contains multiple variants", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", multiVariantManifestResponse),
);
const artifact = await getManifestArtifact(
"https://example.com/multi-variant.ndjson",
"0.10.0",
"x86_64",
"unknown-linux-gnu",
);
expect(artifact).toEqual({
archiveFormat: "zip",
checksum: "checksum-default",
downloadUrl:
"https://example.com/releases/download/0.10.0/uv-x86_64-unknown-linux-gnu-default.zip",
});
});
});

View File

@@ -1,170 +0,0 @@
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockFetch = jest.fn<any>();
jest.unstable_mockModule("../../src/utils/fetch", () => ({
fetch: mockFetch,
}));
const {
clearCache,
fetchVersionData,
getAllVersions,
getArtifact,
getLatestVersion,
parseVersionData,
} = await import("../../src/download/versions-client");
const sampleNdjsonResponse = `{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f"},{"platform":"x86_64-pc-windows-msvc","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip","archive_format":"zip","sha256":"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036"}]}
{"version":"0.9.25","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.25/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"606b3c6949d971709f2526fa0d9f0fd23ccf60e09f117999b406b424af18a6a6"}]}`;
const multiVariantNdjsonResponse = `{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"python-managed","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin-managed.tar.gz","archive_format":"tar.gz","sha256":"managed-checksum"},{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.zip","archive_format":"zip","sha256":"default-checksum"}]}`;
function createMockResponse(
ok: boolean,
status: number,
statusText: string,
data: string,
) {
return {
ok,
status,
statusText,
text: async () => data,
};
}
describe("versions-client", () => {
beforeEach(() => {
clearCache();
mockFetch.mockReset();
});
describe("fetchVersionData", () => {
it("should fetch and parse NDJSON data", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleNdjsonResponse),
);
const versions = await fetchVersionData();
expect(versions).toHaveLength(2);
expect(versions[0].version).toBe("0.9.26");
expect(versions[1].version).toBe("0.9.25");
});
it("should throw error on failed fetch", async () => {
mockFetch.mockResolvedValue(
createMockResponse(false, 500, "Internal Server Error", ""),
);
await expect(fetchVersionData()).rejects.toThrow(
"Failed to fetch version data: 500 Internal Server Error",
);
});
it("should cache results", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleNdjsonResponse),
);
await fetchVersionData();
await fetchVersionData();
expect(mockFetch).toHaveBeenCalledTimes(1);
});
});
describe("getLatestVersion", () => {
it("should return the first version (newest)", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleNdjsonResponse),
);
const latest = await getLatestVersion();
expect(latest).toBe("0.9.26");
});
});
describe("getAllVersions", () => {
it("should return all version strings", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleNdjsonResponse),
);
const versions = await getAllVersions();
expect(versions).toEqual(["0.9.26", "0.9.25"]);
});
});
describe("getArtifact", () => {
beforeEach(() => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", sampleNdjsonResponse),
);
});
it("should find artifact by version and platform", async () => {
const artifact = await getArtifact("0.9.26", "aarch64", "apple-darwin");
expect(artifact).toEqual({
archiveFormat: "tar.gz",
sha256:
"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f",
url: "https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz",
});
});
it("should find windows artifact", async () => {
const artifact = await getArtifact("0.9.26", "x86_64", "pc-windows-msvc");
expect(artifact).toEqual({
archiveFormat: "zip",
sha256:
"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036",
url: "https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip",
});
});
it("should prefer the default variant when multiple artifacts share a platform", async () => {
mockFetch.mockResolvedValue(
createMockResponse(true, 200, "OK", multiVariantNdjsonResponse),
);
const artifact = await getArtifact("0.9.26", "aarch64", "apple-darwin");
expect(artifact).toEqual({
archiveFormat: "zip",
sha256: "default-checksum",
url: "https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.zip",
});
});
it("should return undefined for unknown version", async () => {
const artifact = await getArtifact("0.0.1", "aarch64", "apple-darwin");
expect(artifact).toBeUndefined();
});
it("should return undefined for unknown platform", async () => {
const artifact = await getArtifact(
"0.9.26",
"aarch64",
"unknown-linux-musl",
);
expect(artifact).toBeUndefined();
});
});
describe("parseVersionData", () => {
it("should throw for malformed NDJSON", () => {
expect(() =>
parseVersionData('{"version":"0.1.0"', "test-source"),
).toThrow("Failed to parse version data from test-source");
});
});
});

View File

@@ -75,7 +75,7 @@ inputs:
description: "Custom path to set UV_TOOL_BIN_DIR to." description: "Custom path to set UV_TOOL_BIN_DIR to."
required: false required: false
manifest-file: manifest-file:
description: "URL to a custom manifest file. Supports the astral-sh/versions NDJSON format and the legacy JSON array format (deprecated)." description: "URL to a custom manifest file in the astral-sh/versions format."
required: false required: false
add-problem-matchers: add-problem-matchers:
description: "Add problem matchers." description: "Add problem matchers."

429
dist/setup/index.cjs generated vendored
View File

@@ -91886,7 +91886,7 @@ var semver5 = __toESM(require_semver5(), 1);
var TOOL_CACHE_NAME = "uv"; var TOOL_CACHE_NAME = "uv";
var STATE_UV_PATH = "uv-path"; var STATE_UV_PATH = "uv-path";
var STATE_UV_VERSION = "uv-version"; var STATE_UV_VERSION = "uv-version";
var VERSIONS_NDJSON_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson"; var VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
var GITHUB_RELEASES_PREFIX = "https://github.com/astral-sh/uv/releases/download/"; var GITHUB_RELEASES_PREFIX = "https://github.com/astral-sh/uv/releases/download/";
var ASTRAL_MIRROR_PREFIX = "https://releases.astral.sh/github/uv/releases/download/"; var ASTRAL_MIRROR_PREFIX = "https://releases.astral.sh/github/uv/releases/download/";
@@ -91896,6 +91896,75 @@ var fs11 = __toESM(require("node:fs"), 1);
// src/download/checksum/known-checksums.ts // src/download/checksum/known-checksums.ts
var KNOWN_CHECKSUMS = { var KNOWN_CHECKSUMS = {
"aarch64-apple-darwin-0.11.1": "f7815f739ed5d0e4202e6292acedb8659b9ae7de663d07188d8c6cbd7f96303f",
"aarch64-pc-windows-msvc-0.11.1": "b789db0c1504dd3b02c090bd5783487497cc46cc2eb71754874cdd1ef59eb52a",
"aarch64-unknown-linux-gnu-0.11.1": "1340e62da1ee3c1109764340e1247e8a1a232c30dde4a0f0548976dcaa90f06d",
"aarch64-unknown-linux-musl-0.11.1": "bd04ffce77ee8d77f39823c13606183581847c2f5dcd704f2ea0f15e376b1a27",
"arm-unknown-linux-musleabihf-0.11.1": "625c0e756e2374fce864ceaa6beedd5821e276e2b6307f2b719f2d62b449b89c",
"armv7-unknown-linux-gnueabihf-0.11.1": "baf8daaab20b0502d1853dbfd916afb0762c024ae7f0df1c2deb2a1a1c1c3467",
"armv7-unknown-linux-musleabihf-0.11.1": "684c25b74e83bcb1b177152379cfe2c974ba731aa5af278e1d161e41709f8bcf",
"i686-pc-windows-msvc-0.11.1": "3c07858a08c54e4e5753239354c7b07ae69071b2b6f5aa2cc970e612adcb4740",
"i686-unknown-linux-gnu-0.11.1": "6e83167c05708570563b10b6cc7e8c289daef5f51fde0b152e41af2a7ef70813",
"i686-unknown-linux-musl-0.11.1": "b0d5152635c257fec76f95cb9268112b47ff70bd33a23866295a4f2ed9f46b7f",
"powerpc64le-unknown-linux-gnu-0.11.1": "e42d2abfac46f57564789e2bfa6dbea4ae3135892e36ae066ba0ae77b69bb676",
"riscv64gc-unknown-linux-gnu-0.11.1": "5e2c757b35dab015ad37f74ee3e060208390b5f4defb6684876f1be0664f3f6e",
"riscv64gc-unknown-linux-musl-0.11.1": "6f590a824aed363cbec4079f7ddab87b5685119e0f5f0e71cd114c7b7c326199",
"s390x-unknown-linux-gnu-0.11.1": "4208173c74e29572b799178709b5ed5828b24888659f944a4b47c0aaf78b42d2",
"x86_64-apple-darwin-0.11.1": "2103670e8e949605e51926c7b953923ff6f6befbfb55aee928f5e760c9c910f8",
"x86_64-pc-windows-msvc-0.11.1": "6659250cebbd3bb6ee48bcb21a3f0c6656450d63fb97f0f069bcb532bdb688ed",
"x86_64-unknown-linux-gnu-0.11.1": "7c0c8069053e6e99e5911ff32b916be571f3419cd8e11bd28fb7da2c7dcaa553",
"x86_64-unknown-linux-musl-0.11.1": "4e949471a95b37088a1ff1a585f69abed4d3cd3f921f50709a46b6ba62986d38",
"aarch64-apple-darwin-0.11.0": "0c0f32c6a3473c5928aff96c3233715edfc79290e892f255cac93710cde7b91a",
"aarch64-pc-windows-msvc-0.11.0": "95419e04a3ef5f13fb2a06bd6d787ba80a9d8981d6f097780e5a979817a2879d",
"aarch64-unknown-linux-gnu-0.11.0": "8e179ca110343a17f801444ff9ef117dba56ef5fc9f6a4c9bb77b318ddba5f24",
"aarch64-unknown-linux-musl-0.11.0": "658be4b8ec905635f1295468d4d5120d9e1ab1722eec9a104473ce993590babe",
"arm-unknown-linux-musleabihf-0.11.0": "bfdcbd5fa41c8a9877a72c2b55a95da2bc79933885ef56c699b65bb2ed9cea91",
"armv7-unknown-linux-gnueabihf-0.11.0": "0cad4e1b6769e48aa1e80cf639ddcc7c1bfe9ed017e95868fed185a8d818c949",
"armv7-unknown-linux-musleabihf-0.11.0": "2aa9da83c6c0cf8a06bc9df14d51056284fa067ef5390b4db79998ff12f3bee7",
"i686-pc-windows-msvc-0.11.0": "3b09d70e686087e096dbd8a2af21b922a2cac7d613dc053c3281c3ddbb961961",
"i686-unknown-linux-gnu-0.11.0": "59928a0267501c20d9f9942f5f1d81a991ec55e29a19e002ae3d5c178c674c89",
"i686-unknown-linux-musl-0.11.0": "1f438d6f6f851f0dabad3307ce7fd46541ecc5c42ebb664f382eb6c9a424a67d",
"powerpc64le-unknown-linux-gnu-0.11.0": "29f17fb43595492b1a36cda57df7adad74183132df32799d32897268ff4e26dd",
"riscv64gc-unknown-linux-gnu-0.11.0": "84ef37dda1003c5b65fa6c8f84242d35a7fcc84cc5ea9490d702edc36cad1f67",
"s390x-unknown-linux-gnu-0.11.0": "b25be62f3b642348a2fece5c658624586661b8d1103891ab6903768b0529edc4",
"x86_64-apple-darwin-0.11.0": "31aaec764166af8885cf99321fd6ed24fef80225a6f26ed1ae8ce04111688a7e",
"x86_64-pc-windows-msvc-0.11.0": "e21d00b172df83531564a95e75a2bdc0c59b471dbb3515f0c1b4d6ef657dc451",
"x86_64-unknown-linux-gnu-0.11.0": "cc0fbb42b3642125f600a55b0b095bea65cddaadb94c6ea2b6ba5d79c5825089",
"x86_64-unknown-linux-musl-0.11.0": "bf6b0757c73d1726faa2a819b155d4d864919a95766720215d78fdcd09d42d26",
"aarch64-apple-darwin-0.10.12": "ae738b5661a900579ec621d3918c0ef17bdec0da2a8a6d8b161137cd15f25414",
"aarch64-pc-windows-msvc-0.10.12": "e79881e2c4f98a0f3a37b8770bf224e8fee70f6dcf8fc17055d8291bb1b0b867",
"aarch64-unknown-linux-gnu-0.10.12": "0ed7d20f49f6b9b60d45fdfcac28f3ac01a671a6ef08672401ed2833423fea2a",
"aarch64-unknown-linux-musl-0.10.12": "55bd1c1c10ec8b95a8c184f5e18b566703c6ab105f0fc118aaa4d748aabf28e4",
"arm-unknown-linux-musleabihf-0.10.12": "9714e5059b05110a1c7ddbc18c971c13e0260e10551b7b77d82cbf907a4ebd9b",
"armv7-unknown-linux-gnueabihf-0.10.12": "eaa02f36d5112029601b18ac3d1a0c03a83bb20cb4154c2f5345f777fa6c4101",
"armv7-unknown-linux-musleabihf-0.10.12": "bd735652298c6e62cdd2ac939babe176a3356613e6803baa33d0bc10e8d9e4ed",
"i686-pc-windows-msvc-0.10.12": "2312e75b9c77befdc1bff30da18f16df03083452852952553bee91da362c1a1d",
"i686-unknown-linux-gnu-0.10.12": "8501844b34e3a28cfbba5a4b857eebd696d952e0bb4160357451ad80f3f49db8",
"i686-unknown-linux-musl-0.10.12": "56cad78abcf5b710d2f7b9f774fcfd6bbed340d2aa9d9fc9e3b515542ec5e953",
"powerpc64le-unknown-linux-gnu-0.10.12": "3c8017d9112221c83f43e8a15a58099663c0b2bdeabc8b43bb800413dfa21218",
"riscv64gc-unknown-linux-gnu-0.10.12": "b1ca482b6b5dd7bf6ab733a3695cb0ab5b8e992ca96527efae93aa78fcc52a9b",
"s390x-unknown-linux-gnu-0.10.12": "e1a0345eefe6fd3300948cd6f18aab092f9b88a243782113e645ce96530a6693",
"x86_64-apple-darwin-0.10.12": "17443e293f2ae407bb2d8d34b875ebfe0ae01cf1296de5647e69e7b2e2b428f0",
"x86_64-pc-windows-msvc-0.10.12": "4c1d55501869b3330d4aabf45ad6024ce2367e0f3af83344395702d272c22e88",
"x86_64-unknown-linux-gnu-0.10.12": "ec72570c9d1f33021aa80b176d7baba390de2cfeb1abcbefca346d563bf17484",
"x86_64-unknown-linux-musl-0.10.12": "adccf40b5d1939a5e0093081ec2307ea24235adf7c2d96b122c561fa37711c46",
"aarch64-apple-darwin-0.10.11": "437a7d498dd6564d5bf986074249ba1fc600e73da55ae04d7bd4c24d5f149b95",
"aarch64-pc-windows-msvc-0.10.11": "6a3eec4105c775dd87c11ef8ec41564648273751ff807c8955c24ddbcc636d03",
"aarch64-unknown-linux-gnu-0.10.11": "23003df007937dd607409c8ddf010baa82bad2673e60e254632ca5b04edcce13",
"aarch64-unknown-linux-musl-0.10.11": "5d80a7f6343d2676dfde1e5126582070a2bbc62df6f60d5527a169be3788532a",
"arm-unknown-linux-musleabihf-0.10.11": "d3c248497c450d22a39c1d43a4a358c0c852e6056f5f49be96495eea41afb96c",
"armv7-unknown-linux-gnueabihf-0.10.11": "7895a6470dfba051af4e74253599482fc0b37141b5d229956b383365e1a22902",
"armv7-unknown-linux-musleabihf-0.10.11": "d2880c08acfdaef0985488972c8b14969f7139c27545046e2f6202f0e0f4d9d8",
"i686-pc-windows-msvc-0.10.11": "c17f3dc3b2c47490057f17a1f0c37270f11a7b7cedf9bf2c0f841ce02bc7001b",
"i686-unknown-linux-gnu-0.10.11": "1ab69ff7dd104a902731758ee05b782dfd9bdb263384e61650de638f33f586df",
"i686-unknown-linux-musl-0.10.11": "cffb80d303fc1655e259d0b769c489f452e97425a6b6d3393d766413783a1d8c",
"powerpc64le-unknown-linux-gnu-0.10.11": "ddc6a20670e60219e947b1b04813be80d7e9f4c4a0234231c8ed9298eec04aa6",
"riscv64gc-unknown-linux-gnu-0.10.11": "c0719473cf5f8b475e917b8dfef6ae5d876b86a00a82ef91e47a02f561399f4f",
"s390x-unknown-linux-gnu-0.10.11": "305ee734c585918515a22fe43b7cf253c38d468771373a0c02364d67498e07b2",
"x86_64-apple-darwin-0.10.11": "ff90020b554cf02ef8008535c9aab6ef27bb7be6b075359300dec79c361df897",
"x86_64-pc-windows-msvc-0.10.11": "9ee74df98582f37fdd6069e1caac80d2616f9a489f5dbb2b1c152f30be69c58e",
"x86_64-unknown-linux-gnu-0.10.11": "5a360b0de092ddf4131f5313d0411b48c4e95e8107e40c3f8f2e9fcb636b3583",
"x86_64-unknown-linux-musl-0.10.11": "d78246139dc6cf3ed6d03c84da762686bced7ad1de67977ee372a45b95a1f6d0",
"aarch64-apple-darwin-0.10.10": "8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d", "aarch64-apple-darwin-0.10.10": "8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d",
"aarch64-pc-windows-msvc-0.10.10": "2c6fe113f14574bc27f085751c68d3485589fcc3c3c64ed85dd1eecc2f87cffc", "aarch64-pc-windows-msvc-0.10.10": "2c6fe113f14574bc27f085751c68d3485589fcc3c3c64ed85dd1eecc2f87cffc",
"aarch64-unknown-linux-gnu-0.10.10": "2b80457b950deda12e8d5dc3b9b7494ac143eae47f1fb11b1c6e5a8495a6421e", "aarch64-unknown-linux-gnu-0.10.10": "2b80457b950deda12e8d5dc3b9b7494ac143eae47f1fb11b1c6e5a8495a6421e",
@@ -96339,7 +96408,7 @@ async function validateFileCheckSum(filePath, expected) {
}); });
} }
// src/download/version-manifest.ts // src/download/manifest.ts
var semver4 = __toESM(require_semver5(), 1); var semver4 = __toESM(require_semver5(), 1);
// src/utils/fetch.ts // src/utils/fetch.ts
@@ -96360,45 +96429,6 @@ var fetch = async (url2, opts) => await (0, import_undici2.fetch)(url2, {
...opts ...opts
}); });
// src/download/legacy-version-manifest.ts
var warnedLegacyManifestUrls = /* @__PURE__ */ new Set();
function parseLegacyManifestEntries(parsedEntries, manifestUrl) {
warnAboutLegacyManifestFormat(manifestUrl);
return parsedEntries.map((entry, index) => {
if (!isLegacyManifestEntry(entry)) {
throw new Error(
`Invalid legacy manifest-file entry at index ${index} in ${manifestUrl}.`
);
}
return {
arch: entry.arch,
checksum: entry.checksum,
downloadUrl: entry.downloadUrl,
platform: entry.platform,
version: entry.version
};
});
}
function warnAboutLegacyManifestFormat(manifestUrl) {
if (warnedLegacyManifestUrls.has(manifestUrl)) {
return;
}
warnedLegacyManifestUrls.add(manifestUrl);
warning(
`manifest-file ${manifestUrl} uses the legacy JSON array format, which is deprecated. Please migrate to the astral-sh/versions NDJSON format before the next major release.`
);
}
function isLegacyManifestEntry(value) {
if (!isRecord(value)) {
return false;
}
const checksumIsValid = typeof value.checksum === "string" || value.checksum === void 0;
return typeof value.arch === "string" && checksumIsValid && typeof value.downloadUrl === "string" && typeof value.platform === "string" && typeof value.version === "string";
}
function isRecord(value) {
return typeof value === "object" && value !== null;
}
// src/download/variant-selection.ts // src/download/variant-selection.ts
function selectDefaultVariant(entries, duplicateEntryDescription) { function selectDefaultVariant(entries, duplicateEntryDescription) {
const firstEntry = entries[0]; const firstEntry = entries[0];
@@ -96425,73 +96455,88 @@ function formatVariants(entries) {
return entries.map((entry) => entry.variant ?? "default").sort((left, right) => left.localeCompare(right)).join(", "); return entries.map((entry) => entry.variant ?? "default").sort((left, right) => left.localeCompare(right)).join(", ");
} }
// src/download/versions-client.ts // src/download/manifest.ts
var cachedVersionData = /* @__PURE__ */ new Map(); var cachedManifestData = /* @__PURE__ */ new Map();
async function fetchVersionData(url2 = VERSIONS_NDJSON_URL) { async function fetchManifest(manifestUrl = VERSIONS_MANIFEST_URL) {
const cachedVersions = cachedVersionData.get(url2); const cachedVersions = cachedManifestData.get(manifestUrl);
if (cachedVersions !== void 0) { if (cachedVersions !== void 0) {
debug(`Using cached NDJSON version data from ${url2}`); debug(`Using cached manifest data from ${manifestUrl}`);
return cachedVersions; return cachedVersions;
} }
info(`Fetching version data from ${url2} ...`); info(`Fetching manifest data from ${manifestUrl} ...`);
const response = await fetch(url2, {}); const response = await fetch(manifestUrl, {});
if (!response.ok) { if (!response.ok) {
throw new Error( throw new Error(
`Failed to fetch version data: ${response.status} ${response.statusText}` `Failed to fetch manifest data: ${response.status} ${response.statusText}`
); );
} }
const body2 = await response.text(); const body2 = await response.text();
const versions = parseVersionData(body2, url2); const versions = parseManifest(body2, manifestUrl);
cachedVersionData.set(url2, versions); cachedManifestData.set(manifestUrl, versions);
return versions; return versions;
} }
function parseVersionData(data, sourceDescription) { function parseManifest(data, sourceDescription) {
const trimmed = data.trim();
if (trimmed === "") {
throw new Error(`Manifest at ${sourceDescription} is empty.`);
}
if (trimmed.startsWith("[")) {
throw new Error(
`Legacy JSON array manifests are no longer supported in ${sourceDescription}. Use the astral-sh/versions manifest format instead.`
);
}
const versions = []; const versions = [];
for (const [index, line] of data.split("\n").entries()) { for (const [index, line] of data.split("\n").entries()) {
const trimmed = line.trim(); const record = line.trim();
if (trimmed === "") { if (record === "") {
continue; continue;
} }
let parsed; let parsed;
try { try {
parsed = JSON.parse(trimmed); parsed = JSON.parse(record);
} catch (error2) { } catch (error2) {
throw new Error( throw new Error(
`Failed to parse version data from ${sourceDescription} at line ${index + 1}: ${error2.message}` `Failed to parse manifest data from ${sourceDescription} at line ${index + 1}: ${error2.message}`
); );
} }
if (!isNdjsonVersion(parsed)) { if (!isManifestVersion(parsed)) {
throw new Error( throw new Error(
`Invalid NDJSON record in ${sourceDescription} at line ${index + 1}.` `Invalid manifest record in ${sourceDescription} at line ${index + 1}.`
); );
} }
versions.push(parsed); versions.push(parsed);
} }
if (versions.length === 0) { if (versions.length === 0) {
throw new Error(`No version data found in ${sourceDescription}.`); throw new Error(`No manifest data found in ${sourceDescription}.`);
} }
return versions; return versions;
} }
async function getLatestVersion() { async function getLatestVersion(manifestUrl = VERSIONS_MANIFEST_URL) {
const versions = await fetchVersionData(); const versions = await fetchManifest(manifestUrl);
const latestVersion = versions[0]?.version; const [firstVersion, ...remainingVersions] = versions.map(
if (!latestVersion) { (versionData) => versionData.version
throw new Error("No versions found in NDJSON data"); );
if (firstVersion === void 0) {
throw new Error("No versions found in manifest data");
} }
debug(`Latest version from NDJSON: ${latestVersion}`); const latestVersion = remainingVersions.reduce(
(latest, current) => semver4.gt(current, latest) ? current : latest,
firstVersion
);
debug(`Latest version from manifest: ${latestVersion}`);
return latestVersion; return latestVersion;
} }
async function getAllVersions() { async function getAllVersions(manifestUrl = VERSIONS_MANIFEST_URL) {
const versions = await fetchVersionData(); const versions = await fetchManifest(manifestUrl);
return versions.map((versionData) => versionData.version); return versions.map((versionData) => versionData.version);
} }
async function getArtifact(version4, arch3, platform2) { async function getArtifact(version4, arch3, platform2, manifestUrl = VERSIONS_MANIFEST_URL) {
const versions = await fetchVersionData(); const versions = await fetchManifest(manifestUrl);
const versionData = versions.find( const versionData = versions.find(
(candidate) => candidate.version === version4 (candidate) => candidate.version === version4
); );
if (!versionData) { if (!versionData) {
debug(`Version ${version4} not found in NDJSON data`); debug(`Version ${version4} not found in manifest ${manifestUrl}`);
return void 0; return void 0;
} }
const targetPlatform = `${arch3}-${platform2}`; const targetPlatform = `${arch3}-${platform2}`;
@@ -96504,143 +96549,36 @@ async function getArtifact(version4, arch3, platform2) {
); );
return void 0; return void 0;
} }
const artifact = selectArtifact(matchingArtifacts, version4, targetPlatform); const artifact = selectDefaultVariant(
return { matchingArtifacts,
archiveFormat: artifact.archive_format,
sha256: artifact.sha256,
url: artifact.url
};
}
function selectArtifact(artifacts, version4, targetPlatform) {
return selectDefaultVariant(
artifacts,
`Multiple artifacts found for ${targetPlatform} in version ${version4}` `Multiple artifacts found for ${targetPlatform} in version ${version4}`
); );
return {
archiveFormat: artifact.archive_format,
checksum: artifact.sha256,
downloadUrl: artifact.url
};
} }
function isNdjsonVersion(value) { function isManifestVersion(value) {
if (!isRecord2(value)) { if (!isRecord(value)) {
return false; return false;
} }
if (typeof value.version !== "string" || !Array.isArray(value.artifacts)) { if (typeof value.version !== "string" || !Array.isArray(value.artifacts)) {
return false; return false;
} }
return value.artifacts.every(isNdjsonArtifact); return value.artifacts.every(isManifestArtifact);
} }
function isNdjsonArtifact(value) { function isManifestArtifact(value) {
if (!isRecord2(value)) { if (!isRecord(value)) {
return false; return false;
} }
const variantIsValid = typeof value.variant === "string" || value.variant === void 0; const variantIsValid = typeof value.variant === "string" || value.variant === void 0;
return typeof value.archive_format === "string" && typeof value.platform === "string" && typeof value.sha256 === "string" && typeof value.url === "string" && variantIsValid; return typeof value.archive_format === "string" && typeof value.platform === "string" && typeof value.sha256 === "string" && typeof value.url === "string" && variantIsValid;
} }
function isRecord2(value) { function isRecord(value) {
return typeof value === "object" && value !== null; return typeof value === "object" && value !== null;
} }
// src/download/version-manifest.ts
var cachedManifestEntries = /* @__PURE__ */ new Map();
async function getLatestKnownVersion(manifestUrl) {
const versions = await getAllVersions2(manifestUrl);
const latestVersion = versions.reduce(
(latest, current) => semver4.gt(current, latest) ? current : latest
);
return latestVersion;
}
async function getAllVersions2(manifestUrl) {
const manifestEntries = await getManifestEntries(manifestUrl);
return [...new Set(manifestEntries.map((entry) => entry.version))];
}
async function getManifestArtifact(manifestUrl, version4, arch3, platform2) {
const manifestEntries = await getManifestEntries(manifestUrl);
const entry = selectManifestEntry(
manifestEntries,
manifestUrl,
version4,
arch3,
platform2
);
if (!entry) {
return void 0;
}
return {
archiveFormat: entry.archiveFormat,
checksum: entry.checksum,
downloadUrl: entry.downloadUrl
};
}
async function getManifestEntries(manifestUrl) {
const cachedEntries = cachedManifestEntries.get(manifestUrl);
if (cachedEntries !== void 0) {
debug(`Using cached manifest-file from: ${manifestUrl}`);
return cachedEntries;
}
info(`Fetching manifest-file from: ${manifestUrl}`);
const response = await fetch(manifestUrl, {});
if (!response.ok) {
throw new Error(
`Failed to fetch manifest-file: ${response.status} ${response.statusText}`
);
}
const data = await response.text();
const parsedEntries = parseManifestEntries(data, manifestUrl);
cachedManifestEntries.set(manifestUrl, parsedEntries);
return parsedEntries;
}
function parseManifestEntries(data, manifestUrl) {
const trimmed = data.trim();
if (trimmed === "") {
throw new Error(`manifest-file at ${manifestUrl} is empty.`);
}
const parsedAsJson = tryParseJson(trimmed);
if (Array.isArray(parsedAsJson)) {
return parseLegacyManifestEntries(parsedAsJson, manifestUrl);
}
const versions = parseVersionData(trimmed, manifestUrl);
return mapNdjsonVersionsToManifestEntries(versions, manifestUrl);
}
function mapNdjsonVersionsToManifestEntries(versions, manifestUrl) {
const manifestEntries = [];
for (const versionData of versions) {
for (const artifact of versionData.artifacts) {
const [arch3, ...platformParts] = artifact.platform.split("-");
if (arch3 === void 0 || platformParts.length === 0) {
throw new Error(
`Invalid artifact platform '${artifact.platform}' in manifest-file ${manifestUrl}.`
);
}
manifestEntries.push({
arch: arch3,
archiveFormat: artifact.archive_format,
checksum: artifact.sha256,
downloadUrl: artifact.url,
platform: platformParts.join("-"),
variant: artifact.variant,
version: versionData.version
});
}
}
return manifestEntries;
}
function selectManifestEntry(manifestEntries, manifestUrl, version4, arch3, platform2) {
const matches = manifestEntries.filter(
(candidate) => candidate.version === version4 && candidate.arch === arch3 && candidate.platform === platform2
);
if (matches.length === 0) {
return void 0;
}
return selectDefaultVariant(
matches,
`manifest-file ${manifestUrl} contains multiple artifacts for version ${version4}, arch ${arch3}, platform ${platform2}`
);
}
function tryParseJson(value) {
try {
return JSON.parse(value);
} catch {
return void 0;
}
}
// src/download/download-version.ts // src/download/download-version.ts
function tryGetFromToolCache(arch3, version4) { function tryGetFromToolCache(arch3, version4) {
debug(`Trying to get uv from tool cache for ${version4}...`); debug(`Trying to get uv from tool cache for ${version4}...`);
@@ -96653,24 +96591,25 @@ function tryGetFromToolCache(arch3, version4) {
const installedPath = find(TOOL_CACHE_NAME, resolvedVersion, arch3); const installedPath = find(TOOL_CACHE_NAME, resolvedVersion, arch3);
return { installedPath, version: resolvedVersion }; return { installedPath, version: resolvedVersion };
} }
async function downloadVersionFromNdjson(platform2, arch3, version4, checkSum2, githubToken2) { async function downloadVersion(platform2, arch3, version4, checkSum2, githubToken2, manifestUrl) {
const artifact = await getArtifact(version4, arch3, platform2); const artifact = await getArtifact(version4, arch3, platform2, manifestUrl);
if (!artifact) { if (!artifact) {
throw new Error( throw new Error(
`Could not find artifact for version ${version4}, arch ${arch3}, platform ${platform2} in ${VERSIONS_NDJSON_URL} .` getMissingArtifactMessage(version4, arch3, platform2, manifestUrl)
); );
} }
const mirrorUrl = rewriteToMirror(artifact.url); const checksum = manifestUrl === void 0 ? checkSum2 : resolveChecksum(checkSum2, artifact.checksum);
const downloadUrl = mirrorUrl ?? artifact.url; const mirrorUrl = rewriteToMirror(artifact.downloadUrl);
const downloadUrl = mirrorUrl ?? artifact.downloadUrl;
const downloadToken = mirrorUrl !== void 0 ? void 0 : githubToken2; const downloadToken = mirrorUrl !== void 0 ? void 0 : githubToken2;
try { try {
return await downloadVersion( return await downloadArtifact(
downloadUrl, downloadUrl,
`uv-${arch3}-${platform2}`, `uv-${arch3}-${platform2}`,
platform2, platform2,
arch3, arch3,
version4, version4,
checkSum2, checksum,
downloadToken downloadToken
); );
} catch (err) { } catch (err) {
@@ -96680,13 +96619,13 @@ async function downloadVersionFromNdjson(platform2, arch3, version4, checkSum2,
warning( warning(
`Failed to download from mirror, falling back to GitHub Releases: ${err.message}` `Failed to download from mirror, falling back to GitHub Releases: ${err.message}`
); );
return await downloadVersion( return await downloadArtifact(
artifact.url, artifact.downloadUrl,
`uv-${arch3}-${platform2}`, `uv-${arch3}-${platform2}`,
platform2, platform2,
arch3, arch3,
version4, version4,
checkSum2, checksum,
githubToken2 githubToken2
); );
} }
@@ -96697,29 +96636,7 @@ function rewriteToMirror(url2) {
} }
return ASTRAL_MIRROR_PREFIX + url2.slice(GITHUB_RELEASES_PREFIX.length); return ASTRAL_MIRROR_PREFIX + url2.slice(GITHUB_RELEASES_PREFIX.length);
} }
async function downloadVersionFromManifest(manifestUrl, platform2, arch3, version4, checkSum2, githubToken2) { async function downloadArtifact(downloadUrl, artifactName, platform2, arch3, version4, checksum, githubToken2) {
const artifact = await getManifestArtifact(
manifestUrl,
version4,
arch3,
platform2
);
if (!artifact) {
throw new Error(
`manifest-file does not contain version ${version4}, arch ${arch3}, platform ${platform2}.`
);
}
return await downloadVersion(
artifact.downloadUrl,
`uv-${arch3}-${platform2}`,
platform2,
arch3,
version4,
resolveChecksum(checkSum2, artifact.checksum),
githubToken2
);
}
async function downloadVersion(downloadUrl, artifactName, platform2, arch3, version4, checksum, githubToken2) {
info(`Downloading uv from "${downloadUrl}" ...`); info(`Downloading uv from "${downloadUrl}" ...`);
const downloadPath = await downloadTool( const downloadPath = await downloadTool(
downloadUrl, downloadUrl,
@@ -96752,6 +96669,12 @@ async function downloadVersion(downloadUrl, artifactName, platform2, arch3, vers
); );
return { cachedToolDir, version: version4 }; return { cachedToolDir, version: version4 };
} }
function getMissingArtifactMessage(version4, arch3, platform2, manifestUrl) {
if (manifestUrl === void 0) {
return `Could not find artifact for version ${version4}, arch ${arch3}, platform ${platform2} in ${VERSIONS_MANIFEST_URL} .`;
}
return `manifest-file does not contain version ${version4}, arch ${arch3}, platform ${platform2}.`;
}
function resolveChecksum(checkSum2, manifestChecksum) { function resolveChecksum(checkSum2, manifestChecksum) {
return checkSum2 !== void 0 && checkSum2 !== "" ? checkSum2 : manifestChecksum; return checkSum2 !== void 0 && checkSum2 !== "" ? checkSum2 : manifestChecksum;
} }
@@ -96760,23 +96683,16 @@ function getExtension(platform2) {
} }
async function resolveVersion(versionInput, manifestUrl, resolutionStrategy2 = "highest") { async function resolveVersion(versionInput, manifestUrl, resolutionStrategy2 = "highest") {
debug(`Resolving version: ${versionInput}`); debug(`Resolving version: ${versionInput}`);
let version4;
const isSimpleMinimumVersionSpecifier = versionInput.includes(">") && !versionInput.includes(","); const isSimpleMinimumVersionSpecifier = versionInput.includes(">") && !versionInput.includes(",");
const resolveVersionSpecifierToLatest = isSimpleMinimumVersionSpecifier && resolutionStrategy2 === "highest"; const resolveVersionSpecifierToLatest = isSimpleMinimumVersionSpecifier && resolutionStrategy2 === "highest";
if (resolveVersionSpecifierToLatest) { if (resolveVersionSpecifierToLatest) {
info("Found minimum version specifier, using latest version"); info("Found minimum version specifier, using latest version");
} }
if (manifestUrl !== void 0) { const version4 = versionInput === "latest" || resolveVersionSpecifierToLatest ? await getLatestVersion(manifestUrl) : versionInput;
version4 = versionInput === "latest" || resolveVersionSpecifierToLatest ? await getLatestKnownVersion(manifestUrl) : versionInput;
} else {
version4 = versionInput === "latest" || resolveVersionSpecifierToLatest ? await getLatestVersion() : versionInput;
}
if (isExplicitVersion(version4)) { if (isExplicitVersion(version4)) {
debug(`Version ${version4} is an explicit version.`); debug(`Version ${version4} is an explicit version.`);
if (resolveVersionSpecifierToLatest) { if (resolveVersionSpecifierToLatest && !pep440.satisfies(version4, versionInput)) {
if (!pep440.satisfies(version4, versionInput)) { throw new Error(`No version found for ${versionInput}`);
throw new Error(`No version found for ${versionInput}`);
}
} }
return version4; return version4;
} }
@@ -96793,10 +96709,10 @@ async function getAvailableVersions(manifestUrl) {
info( info(
`Getting available versions from manifest-file ${manifestUrl} ...` `Getting available versions from manifest-file ${manifestUrl} ...`
); );
return await getAllVersions2(manifestUrl); } else {
info(`Getting available versions from ${VERSIONS_MANIFEST_URL} ...`);
} }
info(`Getting available versions from ${VERSIONS_NDJSON_URL} ...`); return await getAllVersions(manifestUrl);
return await getAllVersions();
} }
function maxSatisfying2(versions, version4) { function maxSatisfying2(versions, version4) {
const maxSemver = evaluateVersions(versions, version4); const maxSemver = evaluateVersions(versions, version4);
@@ -96990,7 +96906,7 @@ function detectEmptyWorkdir() {
} }
} }
async function setupUv(platform2, arch3, checkSum2, githubToken2) { async function setupUv(platform2, arch3, checkSum2, githubToken2) {
const resolvedVersion = await determineVersion(manifestFile); const resolvedVersion = await determineVersion();
const toolCacheResult = tryGetFromToolCache(arch3, resolvedVersion); const toolCacheResult = tryGetFromToolCache(arch3, resolvedVersion);
if (toolCacheResult.installedPath) { if (toolCacheResult.installedPath) {
info(`Found uv in tool-cache for ${toolCacheResult.version}`); info(`Found uv in tool-cache for ${toolCacheResult.version}`);
@@ -96999,28 +96915,29 @@ async function setupUv(platform2, arch3, checkSum2, githubToken2) {
version: toolCacheResult.version version: toolCacheResult.version
}; };
} }
const downloadVersionResult = manifestFile !== void 0 ? await downloadVersionFromManifest( const downloadResult = await downloadVersion(
manifestFile,
platform2, platform2,
arch3, arch3,
resolvedVersion, resolvedVersion,
checkSum2, checkSum2,
githubToken2 githubToken2,
) : await downloadVersionFromNdjson( manifestFile
platform2,
arch3,
resolvedVersion,
checkSum2,
githubToken2
); );
return { return {
uvDir: downloadVersionResult.cachedToolDir, uvDir: downloadResult.cachedToolDir,
version: downloadVersionResult.version version: downloadResult.version
}; };
} }
async function determineVersion(manifestFile2) { async function determineVersion() {
return await resolveVersion(
getRequestedVersion(),
manifestFile,
resolutionStrategy
);
}
function getRequestedVersion() {
if (version3 !== "") { if (version3 !== "") {
return await resolveVersion(version3, manifestFile2, resolutionStrategy); return version3;
} }
if (versionFile !== "") { if (versionFile !== "") {
const versionFromFile = getUvVersionFromFile(versionFile); const versionFromFile = getUvVersionFromFile(versionFile);
@@ -97029,11 +96946,7 @@ async function determineVersion(manifestFile2) {
`Could not determine uv version from file: ${versionFile}` `Could not determine uv version from file: ${versionFile}`
); );
} }
return await resolveVersion( return versionFromFile;
versionFromFile,
manifestFile2,
resolutionStrategy
);
} }
const versionFromUvToml = getUvVersionFromFile( const versionFromUvToml = getUvVersionFromFile(
`${workingDirectory}${path15.sep}uv.toml` `${workingDirectory}${path15.sep}uv.toml`
@@ -97046,11 +96959,7 @@ async function determineVersion(manifestFile2) {
"Could not determine uv version from uv.toml or pyproject.toml. Falling back to latest." "Could not determine uv version from uv.toml or pyproject.toml. Falling back to latest."
); );
} }
return await resolveVersion( return versionFromUvToml || versionFromPyproject || "latest";
versionFromUvToml || versionFromPyproject || "latest",
manifestFile2,
resolutionStrategy
);
} }
function addUvToPathAndOutput(cachedPath) { function addUvToPathAndOutput(cachedPath) {
setOutput("uv-path", `${cachedPath}${path15.sep}uv`); setOutput("uv-path", `${cachedPath}${path15.sep}uv`);

167
dist/update-known-checksums/index.cjs generated vendored
View File

@@ -19064,8 +19064,8 @@ var require_semver = __commonJS({
return exports2.compareBuild(b, a, loose); return exports2.compareBuild(b, a, loose);
}); });
} }
exports2.gt = gt; exports2.gt = gt2;
function gt(a, b, loose) { function gt2(a, b, loose) {
return compare(a, b, loose) > 0; return compare(a, b, loose) > 0;
} }
exports2.lt = lt; exports2.lt = lt;
@@ -19110,7 +19110,7 @@ var require_semver = __commonJS({
case "!=": case "!=":
return neq(a, b, loose); return neq(a, b, loose);
case ">": case ">":
return gt(a, b, loose); return gt2(a, b, loose);
case ">=": case ">=":
return gte(a, b, loose); return gte(a, b, loose);
case "<": case "<":
@@ -19608,7 +19608,7 @@ var require_semver = __commonJS({
/* fallthrough */ /* fallthrough */
case "": case "":
case ">=": case ">=":
if (!minver || gt(minver, compver)) { if (!minver || gt2(minver, compver)) {
minver = compver; minver = compver;
} }
break; break;
@@ -19649,7 +19649,7 @@ var require_semver = __commonJS({
var gtfn, ltefn, ltfn, comp, ecomp; var gtfn, ltefn, ltfn, comp, ecomp;
switch (hilo) { switch (hilo) {
case ">": case ">":
gtfn = gt; gtfn = gt2;
ltefn = lte2; ltefn = lte2;
ltfn = lt; ltfn = lt;
comp = ">"; comp = ">";
@@ -19658,7 +19658,7 @@ var require_semver = __commonJS({
case "<": case "<":
gtfn = lt; gtfn = lt;
ltefn = gte; ltefn = gte;
ltfn = gt; ltfn = gt2;
comp = "<"; comp = "<";
ecomp = "<="; ecomp = "<=";
break; break;
@@ -44945,10 +44945,79 @@ function info(message) {
} }
// src/update-known-checksums.ts // src/update-known-checksums.ts
var semver = __toESM(require_semver(), 1); var semver2 = __toESM(require_semver(), 1);
// src/download/checksum/known-checksums.ts // src/download/checksum/known-checksums.ts
var KNOWN_CHECKSUMS = { var KNOWN_CHECKSUMS = {
"aarch64-apple-darwin-0.11.1": "f7815f739ed5d0e4202e6292acedb8659b9ae7de663d07188d8c6cbd7f96303f",
"aarch64-pc-windows-msvc-0.11.1": "b789db0c1504dd3b02c090bd5783487497cc46cc2eb71754874cdd1ef59eb52a",
"aarch64-unknown-linux-gnu-0.11.1": "1340e62da1ee3c1109764340e1247e8a1a232c30dde4a0f0548976dcaa90f06d",
"aarch64-unknown-linux-musl-0.11.1": "bd04ffce77ee8d77f39823c13606183581847c2f5dcd704f2ea0f15e376b1a27",
"arm-unknown-linux-musleabihf-0.11.1": "625c0e756e2374fce864ceaa6beedd5821e276e2b6307f2b719f2d62b449b89c",
"armv7-unknown-linux-gnueabihf-0.11.1": "baf8daaab20b0502d1853dbfd916afb0762c024ae7f0df1c2deb2a1a1c1c3467",
"armv7-unknown-linux-musleabihf-0.11.1": "684c25b74e83bcb1b177152379cfe2c974ba731aa5af278e1d161e41709f8bcf",
"i686-pc-windows-msvc-0.11.1": "3c07858a08c54e4e5753239354c7b07ae69071b2b6f5aa2cc970e612adcb4740",
"i686-unknown-linux-gnu-0.11.1": "6e83167c05708570563b10b6cc7e8c289daef5f51fde0b152e41af2a7ef70813",
"i686-unknown-linux-musl-0.11.1": "b0d5152635c257fec76f95cb9268112b47ff70bd33a23866295a4f2ed9f46b7f",
"powerpc64le-unknown-linux-gnu-0.11.1": "e42d2abfac46f57564789e2bfa6dbea4ae3135892e36ae066ba0ae77b69bb676",
"riscv64gc-unknown-linux-gnu-0.11.1": "5e2c757b35dab015ad37f74ee3e060208390b5f4defb6684876f1be0664f3f6e",
"riscv64gc-unknown-linux-musl-0.11.1": "6f590a824aed363cbec4079f7ddab87b5685119e0f5f0e71cd114c7b7c326199",
"s390x-unknown-linux-gnu-0.11.1": "4208173c74e29572b799178709b5ed5828b24888659f944a4b47c0aaf78b42d2",
"x86_64-apple-darwin-0.11.1": "2103670e8e949605e51926c7b953923ff6f6befbfb55aee928f5e760c9c910f8",
"x86_64-pc-windows-msvc-0.11.1": "6659250cebbd3bb6ee48bcb21a3f0c6656450d63fb97f0f069bcb532bdb688ed",
"x86_64-unknown-linux-gnu-0.11.1": "7c0c8069053e6e99e5911ff32b916be571f3419cd8e11bd28fb7da2c7dcaa553",
"x86_64-unknown-linux-musl-0.11.1": "4e949471a95b37088a1ff1a585f69abed4d3cd3f921f50709a46b6ba62986d38",
"aarch64-apple-darwin-0.11.0": "0c0f32c6a3473c5928aff96c3233715edfc79290e892f255cac93710cde7b91a",
"aarch64-pc-windows-msvc-0.11.0": "95419e04a3ef5f13fb2a06bd6d787ba80a9d8981d6f097780e5a979817a2879d",
"aarch64-unknown-linux-gnu-0.11.0": "8e179ca110343a17f801444ff9ef117dba56ef5fc9f6a4c9bb77b318ddba5f24",
"aarch64-unknown-linux-musl-0.11.0": "658be4b8ec905635f1295468d4d5120d9e1ab1722eec9a104473ce993590babe",
"arm-unknown-linux-musleabihf-0.11.0": "bfdcbd5fa41c8a9877a72c2b55a95da2bc79933885ef56c699b65bb2ed9cea91",
"armv7-unknown-linux-gnueabihf-0.11.0": "0cad4e1b6769e48aa1e80cf639ddcc7c1bfe9ed017e95868fed185a8d818c949",
"armv7-unknown-linux-musleabihf-0.11.0": "2aa9da83c6c0cf8a06bc9df14d51056284fa067ef5390b4db79998ff12f3bee7",
"i686-pc-windows-msvc-0.11.0": "3b09d70e686087e096dbd8a2af21b922a2cac7d613dc053c3281c3ddbb961961",
"i686-unknown-linux-gnu-0.11.0": "59928a0267501c20d9f9942f5f1d81a991ec55e29a19e002ae3d5c178c674c89",
"i686-unknown-linux-musl-0.11.0": "1f438d6f6f851f0dabad3307ce7fd46541ecc5c42ebb664f382eb6c9a424a67d",
"powerpc64le-unknown-linux-gnu-0.11.0": "29f17fb43595492b1a36cda57df7adad74183132df32799d32897268ff4e26dd",
"riscv64gc-unknown-linux-gnu-0.11.0": "84ef37dda1003c5b65fa6c8f84242d35a7fcc84cc5ea9490d702edc36cad1f67",
"s390x-unknown-linux-gnu-0.11.0": "b25be62f3b642348a2fece5c658624586661b8d1103891ab6903768b0529edc4",
"x86_64-apple-darwin-0.11.0": "31aaec764166af8885cf99321fd6ed24fef80225a6f26ed1ae8ce04111688a7e",
"x86_64-pc-windows-msvc-0.11.0": "e21d00b172df83531564a95e75a2bdc0c59b471dbb3515f0c1b4d6ef657dc451",
"x86_64-unknown-linux-gnu-0.11.0": "cc0fbb42b3642125f600a55b0b095bea65cddaadb94c6ea2b6ba5d79c5825089",
"x86_64-unknown-linux-musl-0.11.0": "bf6b0757c73d1726faa2a819b155d4d864919a95766720215d78fdcd09d42d26",
"aarch64-apple-darwin-0.10.12": "ae738b5661a900579ec621d3918c0ef17bdec0da2a8a6d8b161137cd15f25414",
"aarch64-pc-windows-msvc-0.10.12": "e79881e2c4f98a0f3a37b8770bf224e8fee70f6dcf8fc17055d8291bb1b0b867",
"aarch64-unknown-linux-gnu-0.10.12": "0ed7d20f49f6b9b60d45fdfcac28f3ac01a671a6ef08672401ed2833423fea2a",
"aarch64-unknown-linux-musl-0.10.12": "55bd1c1c10ec8b95a8c184f5e18b566703c6ab105f0fc118aaa4d748aabf28e4",
"arm-unknown-linux-musleabihf-0.10.12": "9714e5059b05110a1c7ddbc18c971c13e0260e10551b7b77d82cbf907a4ebd9b",
"armv7-unknown-linux-gnueabihf-0.10.12": "eaa02f36d5112029601b18ac3d1a0c03a83bb20cb4154c2f5345f777fa6c4101",
"armv7-unknown-linux-musleabihf-0.10.12": "bd735652298c6e62cdd2ac939babe176a3356613e6803baa33d0bc10e8d9e4ed",
"i686-pc-windows-msvc-0.10.12": "2312e75b9c77befdc1bff30da18f16df03083452852952553bee91da362c1a1d",
"i686-unknown-linux-gnu-0.10.12": "8501844b34e3a28cfbba5a4b857eebd696d952e0bb4160357451ad80f3f49db8",
"i686-unknown-linux-musl-0.10.12": "56cad78abcf5b710d2f7b9f774fcfd6bbed340d2aa9d9fc9e3b515542ec5e953",
"powerpc64le-unknown-linux-gnu-0.10.12": "3c8017d9112221c83f43e8a15a58099663c0b2bdeabc8b43bb800413dfa21218",
"riscv64gc-unknown-linux-gnu-0.10.12": "b1ca482b6b5dd7bf6ab733a3695cb0ab5b8e992ca96527efae93aa78fcc52a9b",
"s390x-unknown-linux-gnu-0.10.12": "e1a0345eefe6fd3300948cd6f18aab092f9b88a243782113e645ce96530a6693",
"x86_64-apple-darwin-0.10.12": "17443e293f2ae407bb2d8d34b875ebfe0ae01cf1296de5647e69e7b2e2b428f0",
"x86_64-pc-windows-msvc-0.10.12": "4c1d55501869b3330d4aabf45ad6024ce2367e0f3af83344395702d272c22e88",
"x86_64-unknown-linux-gnu-0.10.12": "ec72570c9d1f33021aa80b176d7baba390de2cfeb1abcbefca346d563bf17484",
"x86_64-unknown-linux-musl-0.10.12": "adccf40b5d1939a5e0093081ec2307ea24235adf7c2d96b122c561fa37711c46",
"aarch64-apple-darwin-0.10.11": "437a7d498dd6564d5bf986074249ba1fc600e73da55ae04d7bd4c24d5f149b95",
"aarch64-pc-windows-msvc-0.10.11": "6a3eec4105c775dd87c11ef8ec41564648273751ff807c8955c24ddbcc636d03",
"aarch64-unknown-linux-gnu-0.10.11": "23003df007937dd607409c8ddf010baa82bad2673e60e254632ca5b04edcce13",
"aarch64-unknown-linux-musl-0.10.11": "5d80a7f6343d2676dfde1e5126582070a2bbc62df6f60d5527a169be3788532a",
"arm-unknown-linux-musleabihf-0.10.11": "d3c248497c450d22a39c1d43a4a358c0c852e6056f5f49be96495eea41afb96c",
"armv7-unknown-linux-gnueabihf-0.10.11": "7895a6470dfba051af4e74253599482fc0b37141b5d229956b383365e1a22902",
"armv7-unknown-linux-musleabihf-0.10.11": "d2880c08acfdaef0985488972c8b14969f7139c27545046e2f6202f0e0f4d9d8",
"i686-pc-windows-msvc-0.10.11": "c17f3dc3b2c47490057f17a1f0c37270f11a7b7cedf9bf2c0f841ce02bc7001b",
"i686-unknown-linux-gnu-0.10.11": "1ab69ff7dd104a902731758ee05b782dfd9bdb263384e61650de638f33f586df",
"i686-unknown-linux-musl-0.10.11": "cffb80d303fc1655e259d0b769c489f452e97425a6b6d3393d766413783a1d8c",
"powerpc64le-unknown-linux-gnu-0.10.11": "ddc6a20670e60219e947b1b04813be80d7e9f4c4a0234231c8ed9298eec04aa6",
"riscv64gc-unknown-linux-gnu-0.10.11": "c0719473cf5f8b475e917b8dfef6ae5d876b86a00a82ef91e47a02f561399f4f",
"s390x-unknown-linux-gnu-0.10.11": "305ee734c585918515a22fe43b7cf253c38d468771373a0c02364d67498e07b2",
"x86_64-apple-darwin-0.10.11": "ff90020b554cf02ef8008535c9aab6ef27bb7be6b075359300dec79c361df897",
"x86_64-pc-windows-msvc-0.10.11": "9ee74df98582f37fdd6069e1caac80d2616f9a489f5dbb2b1c152f30be69c58e",
"x86_64-unknown-linux-gnu-0.10.11": "5a360b0de092ddf4131f5313d0411b48c4e95e8107e40c3f8f2e9fcb636b3583",
"x86_64-unknown-linux-musl-0.10.11": "d78246139dc6cf3ed6d03c84da762686bced7ad1de67977ee372a45b95a1f6d0",
"aarch64-apple-darwin-0.10.10": "8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d", "aarch64-apple-darwin-0.10.10": "8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d",
"aarch64-pc-windows-msvc-0.10.10": "2c6fe113f14574bc27f085751c68d3485589fcc3c3c64ed85dd1eecc2f87cffc", "aarch64-pc-windows-msvc-0.10.10": "2c6fe113f14574bc27f085751c68d3485589fcc3c3c64ed85dd1eecc2f87cffc",
"aarch64-unknown-linux-gnu-0.10.10": "2b80457b950deda12e8d5dc3b9b7494ac143eae47f1fb11b1c6e5a8495a6421e", "aarch64-unknown-linux-gnu-0.10.10": "2b80457b950deda12e8d5dc3b9b7494ac143eae47f1fb11b1c6e5a8495a6421e",
@@ -49376,8 +49445,11 @@ async function updateChecksums(filePath, checksumEntries) {
await import_node_fs.promises.writeFile(filePath, content); await import_node_fs.promises.writeFile(filePath, content);
} }
// src/download/manifest.ts
var semver = __toESM(require_semver(), 1);
// src/utils/constants.ts // src/utils/constants.ts
var VERSIONS_NDJSON_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson"; var VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
// src/utils/fetch.ts // src/utils/fetch.ts
var import_undici2 = __toESM(require_undici2(), 1); var import_undici2 = __toESM(require_undici2(), 1);
@@ -49397,72 +49469,87 @@ var fetch = async (url, opts) => await (0, import_undici2.fetch)(url, {
...opts ...opts
}); });
// src/download/versions-client.ts // src/download/manifest.ts
var cachedVersionData = /* @__PURE__ */ new Map(); var cachedManifestData = /* @__PURE__ */ new Map();
async function fetchVersionData(url = VERSIONS_NDJSON_URL) { async function fetchManifest(manifestUrl = VERSIONS_MANIFEST_URL) {
const cachedVersions = cachedVersionData.get(url); const cachedVersions = cachedManifestData.get(manifestUrl);
if (cachedVersions !== void 0) { if (cachedVersions !== void 0) {
debug(`Using cached NDJSON version data from ${url}`); debug(`Using cached manifest data from ${manifestUrl}`);
return cachedVersions; return cachedVersions;
} }
info(`Fetching version data from ${url} ...`); info(`Fetching manifest data from ${manifestUrl} ...`);
const response = await fetch(url, {}); const response = await fetch(manifestUrl, {});
if (!response.ok) { if (!response.ok) {
throw new Error( throw new Error(
`Failed to fetch version data: ${response.status} ${response.statusText}` `Failed to fetch manifest data: ${response.status} ${response.statusText}`
); );
} }
const body = await response.text(); const body = await response.text();
const versions = parseVersionData(body, url); const versions = parseManifest(body, manifestUrl);
cachedVersionData.set(url, versions); cachedManifestData.set(manifestUrl, versions);
return versions; return versions;
} }
function parseVersionData(data, sourceDescription) { function parseManifest(data, sourceDescription) {
const trimmed = data.trim();
if (trimmed === "") {
throw new Error(`Manifest at ${sourceDescription} is empty.`);
}
if (trimmed.startsWith("[")) {
throw new Error(
`Legacy JSON array manifests are no longer supported in ${sourceDescription}. Use the astral-sh/versions manifest format instead.`
);
}
const versions = []; const versions = [];
for (const [index, line] of data.split("\n").entries()) { for (const [index, line] of data.split("\n").entries()) {
const trimmed = line.trim(); const record = line.trim();
if (trimmed === "") { if (record === "") {
continue; continue;
} }
let parsed; let parsed;
try { try {
parsed = JSON.parse(trimmed); parsed = JSON.parse(record);
} catch (error) { } catch (error) {
throw new Error( throw new Error(
`Failed to parse version data from ${sourceDescription} at line ${index + 1}: ${error.message}` `Failed to parse manifest data from ${sourceDescription} at line ${index + 1}: ${error.message}`
); );
} }
if (!isNdjsonVersion(parsed)) { if (!isManifestVersion(parsed)) {
throw new Error( throw new Error(
`Invalid NDJSON record in ${sourceDescription} at line ${index + 1}.` `Invalid manifest record in ${sourceDescription} at line ${index + 1}.`
); );
} }
versions.push(parsed); versions.push(parsed);
} }
if (versions.length === 0) { if (versions.length === 0) {
throw new Error(`No version data found in ${sourceDescription}.`); throw new Error(`No manifest data found in ${sourceDescription}.`);
} }
return versions; return versions;
} }
async function getLatestVersion() { async function getLatestVersion(manifestUrl = VERSIONS_MANIFEST_URL) {
const versions = await fetchVersionData(); const versions = await fetchManifest(manifestUrl);
const latestVersion = versions[0]?.version; const [firstVersion, ...remainingVersions] = versions.map(
if (!latestVersion) { (versionData) => versionData.version
throw new Error("No versions found in NDJSON data"); );
if (firstVersion === void 0) {
throw new Error("No versions found in manifest data");
} }
debug(`Latest version from NDJSON: ${latestVersion}`); const latestVersion = remainingVersions.reduce(
(latest, current) => semver.gt(current, latest) ? current : latest,
firstVersion
);
debug(`Latest version from manifest: ${latestVersion}`);
return latestVersion; return latestVersion;
} }
function isNdjsonVersion(value) { function isManifestVersion(value) {
if (!isRecord(value)) { if (!isRecord(value)) {
return false; return false;
} }
if (typeof value.version !== "string" || !Array.isArray(value.artifacts)) { if (typeof value.version !== "string" || !Array.isArray(value.artifacts)) {
return false; return false;
} }
return value.artifacts.every(isNdjsonArtifact); return value.artifacts.every(isManifestArtifact);
} }
function isNdjsonArtifact(value) { function isManifestArtifact(value) {
if (!isRecord(value)) { if (!isRecord(value)) {
return false; return false;
} }
@@ -49484,14 +49571,14 @@ async function run() {
} }
const latestVersion = await getLatestVersion(); const latestVersion = await getLatestVersion();
const latestKnownVersion = getLatestKnownVersionFromChecksums(); const latestKnownVersion = getLatestKnownVersionFromChecksums();
if (semver.lte(latestVersion, latestKnownVersion)) { if (semver2.lte(latestVersion, latestKnownVersion)) {
info( info(
`Latest release (${latestVersion}) is not newer than the latest known version (${latestKnownVersion}). Skipping update.` `Latest release (${latestVersion}) is not newer than the latest known version (${latestKnownVersion}). Skipping update.`
); );
return; return;
} }
const versions = await fetchVersionData(); const versions = await fetchManifest();
const checksumEntries = extractChecksumsFromNdjson(versions); const checksumEntries = extractChecksumsFromManifest(versions);
await updateChecksums(checksumFilePath, checksumEntries); await updateChecksums(checksumFilePath, checksumEntries);
setOutput("latest-version", latestVersion); setOutput("latest-version", latestVersion);
} }
@@ -49503,7 +49590,7 @@ function getLatestKnownVersionFromChecksums() {
versions.add(version); versions.add(version);
} }
} }
const latestVersion = [...versions].sort(semver.rcompare)[0]; const latestVersion = [...versions].sort(semver2.rcompare)[0];
if (!latestVersion) { if (!latestVersion) {
throw new Error("Could not determine latest known version from checksums."); throw new Error("Could not determine latest known version from checksums.");
} }
@@ -49512,7 +49599,7 @@ function getLatestKnownVersionFromChecksums() {
function extractVersionFromChecksumKey(key) { function extractVersionFromChecksumKey(key) {
return key.match(VERSION_IN_CHECKSUM_KEY_PATTERN)?.[1]; return key.match(VERSION_IN_CHECKSUM_KEY_PATTERN)?.[1];
} }
function extractChecksumsFromNdjson(versions) { function extractChecksumsFromManifest(versions) {
const checksums = []; const checksums = [];
for (const version of versions) { for (const version of versions) {
for (const artifact of version.artifacts) { for (const artifact of version.artifacts) {

View File

@@ -19,14 +19,14 @@ are automatically verified by this action. The sha256 hashes can be found on the
## Manifest file ## Manifest file
By default, setup-uv reads version metadata from By default, setup-uv reads version metadata from
[`astral-sh/versions`](https://github.com/astral-sh/versions) (NDJSON format). [`astral-sh/versions`](https://github.com/astral-sh/versions).
The `manifest-file` input lets you override that source with your own URL, for example to test The `manifest-file` input lets you override that source with your own URL, for example to test
custom uv builds or alternate download locations. custom uv builds or alternate download locations.
### Format ### Format
The manifest file must be in NDJSON format, where each line is a JSON object representing a version and its artifacts. For example: The manifest file must use the same format as `astral-sh/versions`: one JSON object per line, where each object represents a version and its artifacts. The versions must be sorted in descending order. For example:
```json ```json
{"version":"0.10.7","artifacts":[{"platform":"x86_64-unknown-linux-gnu","variant":"default","url":"https://example.com/uv-x86_64-unknown-linux-gnu.tar.gz","archive_format":"tar.gz","sha256":"..."}]} {"version":"0.10.7","artifacts":[{"platform":"x86_64-unknown-linux-gnu","variant":"default","url":"https://example.com/uv-x86_64-unknown-linux-gnu.tar.gz","archive_format":"tar.gz","sha256":"..."}]}
@@ -37,23 +37,6 @@ setup-uv currently only supports `default` as the `variant`.
The `archive_format` field is currently ignored. The `archive_format` field is currently ignored.
### Legacy format: JSON array (deprecated)
The previous JSON array format is still supported for compatibility, but deprecated and will be
removed in a future major release.
```json
[
{
"version": "0.7.13",
"artifactName": "uv-aarch64-apple-darwin.tar.gz",
"arch": "aarch64",
"platform": "apple-darwin",
"downloadUrl": "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-aarch64-apple-darwin.tar.gz"
}
]
```
```yaml ```yaml
- name: Use a custom manifest file - name: Use a custom manifest file
uses: astral-sh/setup-uv@v7 uses: astral-sh/setup-uv@v7

View File

@@ -1,5 +1,143 @@
// AUTOGENERATED_DO_NOT_EDIT // AUTOGENERATED_DO_NOT_EDIT
export const KNOWN_CHECKSUMS: { [key: string]: string } = { export const KNOWN_CHECKSUMS: { [key: string]: string } = {
"aarch64-apple-darwin-0.11.1":
"f7815f739ed5d0e4202e6292acedb8659b9ae7de663d07188d8c6cbd7f96303f",
"aarch64-pc-windows-msvc-0.11.1":
"b789db0c1504dd3b02c090bd5783487497cc46cc2eb71754874cdd1ef59eb52a",
"aarch64-unknown-linux-gnu-0.11.1":
"1340e62da1ee3c1109764340e1247e8a1a232c30dde4a0f0548976dcaa90f06d",
"aarch64-unknown-linux-musl-0.11.1":
"bd04ffce77ee8d77f39823c13606183581847c2f5dcd704f2ea0f15e376b1a27",
"arm-unknown-linux-musleabihf-0.11.1":
"625c0e756e2374fce864ceaa6beedd5821e276e2b6307f2b719f2d62b449b89c",
"armv7-unknown-linux-gnueabihf-0.11.1":
"baf8daaab20b0502d1853dbfd916afb0762c024ae7f0df1c2deb2a1a1c1c3467",
"armv7-unknown-linux-musleabihf-0.11.1":
"684c25b74e83bcb1b177152379cfe2c974ba731aa5af278e1d161e41709f8bcf",
"i686-pc-windows-msvc-0.11.1":
"3c07858a08c54e4e5753239354c7b07ae69071b2b6f5aa2cc970e612adcb4740",
"i686-unknown-linux-gnu-0.11.1":
"6e83167c05708570563b10b6cc7e8c289daef5f51fde0b152e41af2a7ef70813",
"i686-unknown-linux-musl-0.11.1":
"b0d5152635c257fec76f95cb9268112b47ff70bd33a23866295a4f2ed9f46b7f",
"powerpc64le-unknown-linux-gnu-0.11.1":
"e42d2abfac46f57564789e2bfa6dbea4ae3135892e36ae066ba0ae77b69bb676",
"riscv64gc-unknown-linux-gnu-0.11.1":
"5e2c757b35dab015ad37f74ee3e060208390b5f4defb6684876f1be0664f3f6e",
"riscv64gc-unknown-linux-musl-0.11.1":
"6f590a824aed363cbec4079f7ddab87b5685119e0f5f0e71cd114c7b7c326199",
"s390x-unknown-linux-gnu-0.11.1":
"4208173c74e29572b799178709b5ed5828b24888659f944a4b47c0aaf78b42d2",
"x86_64-apple-darwin-0.11.1":
"2103670e8e949605e51926c7b953923ff6f6befbfb55aee928f5e760c9c910f8",
"x86_64-pc-windows-msvc-0.11.1":
"6659250cebbd3bb6ee48bcb21a3f0c6656450d63fb97f0f069bcb532bdb688ed",
"x86_64-unknown-linux-gnu-0.11.1":
"7c0c8069053e6e99e5911ff32b916be571f3419cd8e11bd28fb7da2c7dcaa553",
"x86_64-unknown-linux-musl-0.11.1":
"4e949471a95b37088a1ff1a585f69abed4d3cd3f921f50709a46b6ba62986d38",
"aarch64-apple-darwin-0.11.0":
"0c0f32c6a3473c5928aff96c3233715edfc79290e892f255cac93710cde7b91a",
"aarch64-pc-windows-msvc-0.11.0":
"95419e04a3ef5f13fb2a06bd6d787ba80a9d8981d6f097780e5a979817a2879d",
"aarch64-unknown-linux-gnu-0.11.0":
"8e179ca110343a17f801444ff9ef117dba56ef5fc9f6a4c9bb77b318ddba5f24",
"aarch64-unknown-linux-musl-0.11.0":
"658be4b8ec905635f1295468d4d5120d9e1ab1722eec9a104473ce993590babe",
"arm-unknown-linux-musleabihf-0.11.0":
"bfdcbd5fa41c8a9877a72c2b55a95da2bc79933885ef56c699b65bb2ed9cea91",
"armv7-unknown-linux-gnueabihf-0.11.0":
"0cad4e1b6769e48aa1e80cf639ddcc7c1bfe9ed017e95868fed185a8d818c949",
"armv7-unknown-linux-musleabihf-0.11.0":
"2aa9da83c6c0cf8a06bc9df14d51056284fa067ef5390b4db79998ff12f3bee7",
"i686-pc-windows-msvc-0.11.0":
"3b09d70e686087e096dbd8a2af21b922a2cac7d613dc053c3281c3ddbb961961",
"i686-unknown-linux-gnu-0.11.0":
"59928a0267501c20d9f9942f5f1d81a991ec55e29a19e002ae3d5c178c674c89",
"i686-unknown-linux-musl-0.11.0":
"1f438d6f6f851f0dabad3307ce7fd46541ecc5c42ebb664f382eb6c9a424a67d",
"powerpc64le-unknown-linux-gnu-0.11.0":
"29f17fb43595492b1a36cda57df7adad74183132df32799d32897268ff4e26dd",
"riscv64gc-unknown-linux-gnu-0.11.0":
"84ef37dda1003c5b65fa6c8f84242d35a7fcc84cc5ea9490d702edc36cad1f67",
"s390x-unknown-linux-gnu-0.11.0":
"b25be62f3b642348a2fece5c658624586661b8d1103891ab6903768b0529edc4",
"x86_64-apple-darwin-0.11.0":
"31aaec764166af8885cf99321fd6ed24fef80225a6f26ed1ae8ce04111688a7e",
"x86_64-pc-windows-msvc-0.11.0":
"e21d00b172df83531564a95e75a2bdc0c59b471dbb3515f0c1b4d6ef657dc451",
"x86_64-unknown-linux-gnu-0.11.0":
"cc0fbb42b3642125f600a55b0b095bea65cddaadb94c6ea2b6ba5d79c5825089",
"x86_64-unknown-linux-musl-0.11.0":
"bf6b0757c73d1726faa2a819b155d4d864919a95766720215d78fdcd09d42d26",
"aarch64-apple-darwin-0.10.12":
"ae738b5661a900579ec621d3918c0ef17bdec0da2a8a6d8b161137cd15f25414",
"aarch64-pc-windows-msvc-0.10.12":
"e79881e2c4f98a0f3a37b8770bf224e8fee70f6dcf8fc17055d8291bb1b0b867",
"aarch64-unknown-linux-gnu-0.10.12":
"0ed7d20f49f6b9b60d45fdfcac28f3ac01a671a6ef08672401ed2833423fea2a",
"aarch64-unknown-linux-musl-0.10.12":
"55bd1c1c10ec8b95a8c184f5e18b566703c6ab105f0fc118aaa4d748aabf28e4",
"arm-unknown-linux-musleabihf-0.10.12":
"9714e5059b05110a1c7ddbc18c971c13e0260e10551b7b77d82cbf907a4ebd9b",
"armv7-unknown-linux-gnueabihf-0.10.12":
"eaa02f36d5112029601b18ac3d1a0c03a83bb20cb4154c2f5345f777fa6c4101",
"armv7-unknown-linux-musleabihf-0.10.12":
"bd735652298c6e62cdd2ac939babe176a3356613e6803baa33d0bc10e8d9e4ed",
"i686-pc-windows-msvc-0.10.12":
"2312e75b9c77befdc1bff30da18f16df03083452852952553bee91da362c1a1d",
"i686-unknown-linux-gnu-0.10.12":
"8501844b34e3a28cfbba5a4b857eebd696d952e0bb4160357451ad80f3f49db8",
"i686-unknown-linux-musl-0.10.12":
"56cad78abcf5b710d2f7b9f774fcfd6bbed340d2aa9d9fc9e3b515542ec5e953",
"powerpc64le-unknown-linux-gnu-0.10.12":
"3c8017d9112221c83f43e8a15a58099663c0b2bdeabc8b43bb800413dfa21218",
"riscv64gc-unknown-linux-gnu-0.10.12":
"b1ca482b6b5dd7bf6ab733a3695cb0ab5b8e992ca96527efae93aa78fcc52a9b",
"s390x-unknown-linux-gnu-0.10.12":
"e1a0345eefe6fd3300948cd6f18aab092f9b88a243782113e645ce96530a6693",
"x86_64-apple-darwin-0.10.12":
"17443e293f2ae407bb2d8d34b875ebfe0ae01cf1296de5647e69e7b2e2b428f0",
"x86_64-pc-windows-msvc-0.10.12":
"4c1d55501869b3330d4aabf45ad6024ce2367e0f3af83344395702d272c22e88",
"x86_64-unknown-linux-gnu-0.10.12":
"ec72570c9d1f33021aa80b176d7baba390de2cfeb1abcbefca346d563bf17484",
"x86_64-unknown-linux-musl-0.10.12":
"adccf40b5d1939a5e0093081ec2307ea24235adf7c2d96b122c561fa37711c46",
"aarch64-apple-darwin-0.10.11":
"437a7d498dd6564d5bf986074249ba1fc600e73da55ae04d7bd4c24d5f149b95",
"aarch64-pc-windows-msvc-0.10.11":
"6a3eec4105c775dd87c11ef8ec41564648273751ff807c8955c24ddbcc636d03",
"aarch64-unknown-linux-gnu-0.10.11":
"23003df007937dd607409c8ddf010baa82bad2673e60e254632ca5b04edcce13",
"aarch64-unknown-linux-musl-0.10.11":
"5d80a7f6343d2676dfde1e5126582070a2bbc62df6f60d5527a169be3788532a",
"arm-unknown-linux-musleabihf-0.10.11":
"d3c248497c450d22a39c1d43a4a358c0c852e6056f5f49be96495eea41afb96c",
"armv7-unknown-linux-gnueabihf-0.10.11":
"7895a6470dfba051af4e74253599482fc0b37141b5d229956b383365e1a22902",
"armv7-unknown-linux-musleabihf-0.10.11":
"d2880c08acfdaef0985488972c8b14969f7139c27545046e2f6202f0e0f4d9d8",
"i686-pc-windows-msvc-0.10.11":
"c17f3dc3b2c47490057f17a1f0c37270f11a7b7cedf9bf2c0f841ce02bc7001b",
"i686-unknown-linux-gnu-0.10.11":
"1ab69ff7dd104a902731758ee05b782dfd9bdb263384e61650de638f33f586df",
"i686-unknown-linux-musl-0.10.11":
"cffb80d303fc1655e259d0b769c489f452e97425a6b6d3393d766413783a1d8c",
"powerpc64le-unknown-linux-gnu-0.10.11":
"ddc6a20670e60219e947b1b04813be80d7e9f4c4a0234231c8ed9298eec04aa6",
"riscv64gc-unknown-linux-gnu-0.10.11":
"c0719473cf5f8b475e917b8dfef6ae5d876b86a00a82ef91e47a02f561399f4f",
"s390x-unknown-linux-gnu-0.10.11":
"305ee734c585918515a22fe43b7cf253c38d468771373a0c02364d67498e07b2",
"x86_64-apple-darwin-0.10.11":
"ff90020b554cf02ef8008535c9aab6ef27bb7be6b075359300dec79c361df897",
"x86_64-pc-windows-msvc-0.10.11":
"9ee74df98582f37fdd6069e1caac80d2616f9a489f5dbb2b1c152f30be69c58e",
"x86_64-unknown-linux-gnu-0.10.11":
"5a360b0de092ddf4131f5313d0411b48c4e95e8107e40c3f8f2e9fcb636b3583",
"x86_64-unknown-linux-musl-0.10.11":
"d78246139dc6cf3ed6d03c84da762686bced7ad1de67977ee372a45b95a1f6d0",
"aarch64-apple-darwin-0.10.10": "aarch64-apple-darwin-0.10.10":
"8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d", "8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d",
"aarch64-pc-windows-msvc-0.10.10": "aarch64-pc-windows-msvc-0.10.10":

View File

@@ -8,20 +8,11 @@ import {
ASTRAL_MIRROR_PREFIX, ASTRAL_MIRROR_PREFIX,
GITHUB_RELEASES_PREFIX, GITHUB_RELEASES_PREFIX,
TOOL_CACHE_NAME, TOOL_CACHE_NAME,
VERSIONS_NDJSON_URL, VERSIONS_MANIFEST_URL,
} from "../utils/constants"; } from "../utils/constants";
import type { Architecture, Platform } from "../utils/platforms"; import type { Architecture, Platform } from "../utils/platforms";
import { validateChecksum } from "./checksum/checksum"; import { validateChecksum } from "./checksum/checksum";
import { import { getAllVersions, getArtifact, getLatestVersion } from "./manifest";
getAllVersions as getAllManifestVersions,
getLatestKnownVersion as getLatestVersionInManifest,
getManifestArtifact,
} from "./version-manifest";
import {
getAllVersions as getAllVersionsFromNdjson,
getArtifact as getArtifactFromNdjson,
getLatestVersion as getLatestVersionFromNdjson,
} from "./versions-client";
export function tryGetFromToolCache( export function tryGetFromToolCache(
arch: Architecture, arch: Architecture,
@@ -38,36 +29,42 @@ export function tryGetFromToolCache(
return { installedPath, version: resolvedVersion }; return { installedPath, version: resolvedVersion };
} }
export async function downloadVersionFromNdjson( export async function downloadVersion(
platform: Platform, platform: Platform,
arch: Architecture, arch: Architecture,
version: string, version: string,
checkSum: string | undefined, checkSum: string | undefined,
githubToken: string, githubToken: string,
manifestUrl?: string,
): Promise<{ version: string; cachedToolDir: string }> { ): Promise<{ version: string; cachedToolDir: string }> {
const artifact = await getArtifactFromNdjson(version, arch, platform); const artifact = await getArtifact(version, arch, platform, manifestUrl);
if (!artifact) { if (!artifact) {
throw new Error( throw new Error(
`Could not find artifact for version ${version}, arch ${arch}, platform ${platform} in ${VERSIONS_NDJSON_URL} .`, getMissingArtifactMessage(version, arch, platform, manifestUrl),
); );
} }
const mirrorUrl = rewriteToMirror(artifact.url); // For the default astral-sh/versions source, checksum validation relies on
const downloadUrl = mirrorUrl ?? artifact.url; // user input or the built-in KNOWN_CHECKSUMS table, not manifest sha256 values.
const checksum =
manifestUrl === undefined
? checkSum
: resolveChecksum(checkSum, artifact.checksum);
const mirrorUrl = rewriteToMirror(artifact.downloadUrl);
const downloadUrl = mirrorUrl ?? artifact.downloadUrl;
// Don't send the GitHub token to the Astral mirror. // Don't send the GitHub token to the Astral mirror.
const downloadToken = mirrorUrl !== undefined ? undefined : githubToken; const downloadToken = mirrorUrl !== undefined ? undefined : githubToken;
// For the default astral-sh/versions source, checksum validation relies on
// user input or the built-in KNOWN_CHECKSUMS table, not NDJSON sha256 values.
try { try {
return await downloadVersion( return await downloadArtifact(
downloadUrl, downloadUrl,
`uv-${arch}-${platform}`, `uv-${arch}-${platform}`,
platform, platform,
arch, arch,
version, version,
checkSum, checksum,
downloadToken, downloadToken,
); );
} catch (err) { } catch (err) {
@@ -79,13 +76,13 @@ export async function downloadVersionFromNdjson(
`Failed to download from mirror, falling back to GitHub Releases: ${(err as Error).message}`, `Failed to download from mirror, falling back to GitHub Releases: ${(err as Error).message}`,
); );
return await downloadVersion( return await downloadArtifact(
artifact.url, artifact.downloadUrl,
`uv-${arch}-${platform}`, `uv-${arch}-${platform}`,
platform, platform,
arch, arch,
version, version,
checkSum, checksum,
githubToken, githubToken,
); );
} }
@@ -99,41 +96,11 @@ export function rewriteToMirror(url: string): string | undefined {
if (!url.startsWith(GITHUB_RELEASES_PREFIX)) { if (!url.startsWith(GITHUB_RELEASES_PREFIX)) {
return undefined; return undefined;
} }
return ASTRAL_MIRROR_PREFIX + url.slice(GITHUB_RELEASES_PREFIX.length); return ASTRAL_MIRROR_PREFIX + url.slice(GITHUB_RELEASES_PREFIX.length);
} }
export async function downloadVersionFromManifest( async function downloadArtifact(
manifestUrl: string,
platform: Platform,
arch: Architecture,
version: string,
checkSum: string | undefined,
githubToken: string,
): Promise<{ version: string; cachedToolDir: string }> {
const artifact = await getManifestArtifact(
manifestUrl,
version,
arch,
platform,
);
if (!artifact) {
throw new Error(
`manifest-file does not contain version ${version}, arch ${arch}, platform ${platform}.`,
);
}
return await downloadVersion(
artifact.downloadUrl,
`uv-${arch}-${platform}`,
platform,
arch,
version,
resolveChecksum(checkSum, artifact.checksum),
githubToken,
);
}
async function downloadVersion(
downloadUrl: string, downloadUrl: string,
artifactName: string, artifactName: string,
platform: Platform, platform: Platform,
@@ -177,13 +144,26 @@ async function downloadVersion(
version, version,
arch, arch,
); );
return { cachedToolDir, version: version }; return { cachedToolDir, version };
}
function getMissingArtifactMessage(
version: string,
arch: Architecture,
platform: Platform,
manifestUrl?: string,
): string {
if (manifestUrl === undefined) {
return `Could not find artifact for version ${version}, arch ${arch}, platform ${platform} in ${VERSIONS_MANIFEST_URL} .`;
}
return `manifest-file does not contain version ${version}, arch ${arch}, platform ${platform}.`;
} }
function resolveChecksum( function resolveChecksum(
checkSum: string | undefined, checkSum: string | undefined,
manifestChecksum?: string, manifestChecksum: string,
): string | undefined { ): string {
return checkSum !== undefined && checkSum !== "" return checkSum !== undefined && checkSum !== ""
? checkSum ? checkSum
: manifestChecksum; : manifestChecksum;
@@ -199,31 +179,27 @@ export async function resolveVersion(
resolutionStrategy: "highest" | "lowest" = "highest", resolutionStrategy: "highest" | "lowest" = "highest",
): Promise<string> { ): Promise<string> {
core.debug(`Resolving version: ${versionInput}`); core.debug(`Resolving version: ${versionInput}`);
let version: string;
const isSimpleMinimumVersionSpecifier = const isSimpleMinimumVersionSpecifier =
versionInput.includes(">") && !versionInput.includes(","); versionInput.includes(">") && !versionInput.includes(",");
const resolveVersionSpecifierToLatest = const resolveVersionSpecifierToLatest =
isSimpleMinimumVersionSpecifier && resolutionStrategy === "highest"; isSimpleMinimumVersionSpecifier && resolutionStrategy === "highest";
if (resolveVersionSpecifierToLatest) { if (resolveVersionSpecifierToLatest) {
core.info("Found minimum version specifier, using latest version"); core.info("Found minimum version specifier, using latest version");
} }
if (manifestUrl !== undefined) {
version = const version =
versionInput === "latest" || resolveVersionSpecifierToLatest versionInput === "latest" || resolveVersionSpecifierToLatest
? await getLatestVersionInManifest(manifestUrl) ? await getLatestVersion(manifestUrl)
: versionInput; : versionInput;
} else {
version =
versionInput === "latest" || resolveVersionSpecifierToLatest
? await getLatestVersionFromNdjson()
: versionInput;
}
if (tc.isExplicitVersion(version)) { if (tc.isExplicitVersion(version)) {
core.debug(`Version ${version} is an explicit version.`); core.debug(`Version ${version} is an explicit version.`);
if (resolveVersionSpecifierToLatest) { if (
if (!pep440.satisfies(version, versionInput)) { resolveVersionSpecifierToLatest &&
throw new Error(`No version found for ${versionInput}`); !pep440.satisfies(version, versionInput)
} ) {
throw new Error(`No version found for ${versionInput}`);
} }
return version; return version;
} }
@@ -249,11 +225,11 @@ async function getAvailableVersions(
core.info( core.info(
`Getting available versions from manifest-file ${manifestUrl} ...`, `Getting available versions from manifest-file ${manifestUrl} ...`,
); );
return await getAllManifestVersions(manifestUrl); } else {
core.info(`Getting available versions from ${VERSIONS_MANIFEST_URL} ...`);
} }
core.info(`Getting available versions from ${VERSIONS_NDJSON_URL} ...`); return await getAllVersions(manifestUrl);
return await getAllVersionsFromNdjson();
} }
function maxSatisfying( function maxSatisfying(

View File

@@ -1,80 +0,0 @@
import * as core from "@actions/core";
export interface ManifestEntry {
arch: string;
platform: string;
version: string;
downloadUrl: string;
checksum?: string;
variant?: string;
archiveFormat?: string;
}
interface LegacyManifestEntry {
arch: string;
platform: string;
version: string;
downloadUrl: string;
checksum?: string;
}
const warnedLegacyManifestUrls = new Set<string>();
export function parseLegacyManifestEntries(
parsedEntries: unknown[],
manifestUrl: string,
): ManifestEntry[] {
warnAboutLegacyManifestFormat(manifestUrl);
return parsedEntries.map((entry, index) => {
if (!isLegacyManifestEntry(entry)) {
throw new Error(
`Invalid legacy manifest-file entry at index ${index} in ${manifestUrl}.`,
);
}
return {
arch: entry.arch,
checksum: entry.checksum,
downloadUrl: entry.downloadUrl,
platform: entry.platform,
version: entry.version,
};
});
}
export function clearLegacyManifestWarnings(): void {
warnedLegacyManifestUrls.clear();
}
function warnAboutLegacyManifestFormat(manifestUrl: string): void {
if (warnedLegacyManifestUrls.has(manifestUrl)) {
return;
}
warnedLegacyManifestUrls.add(manifestUrl);
core.warning(
`manifest-file ${manifestUrl} uses the legacy JSON array format, which is deprecated. Please migrate to the astral-sh/versions NDJSON format before the next major release.`,
);
}
function isLegacyManifestEntry(value: unknown): value is LegacyManifestEntry {
if (!isRecord(value)) {
return false;
}
const checksumIsValid =
typeof value.checksum === "string" || value.checksum === undefined;
return (
typeof value.arch === "string" &&
checksumIsValid &&
typeof value.downloadUrl === "string" &&
typeof value.platform === "string" &&
typeof value.version === "string"
);
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
}

208
src/download/manifest.ts Normal file
View File

@@ -0,0 +1,208 @@
import * as core from "@actions/core";
import * as semver from "semver";
import { VERSIONS_MANIFEST_URL } from "../utils/constants";
import { fetch } from "../utils/fetch";
import { selectDefaultVariant } from "./variant-selection";
export interface ManifestArtifact {
platform: string;
variant?: string;
url: string;
archive_format: string;
sha256: string;
}
export interface ManifestVersion {
version: string;
artifacts: ManifestArtifact[];
}
export interface ArtifactResult {
archiveFormat: string;
checksum: string;
downloadUrl: string;
}
const cachedManifestData = new Map<string, ManifestVersion[]>();
export async function fetchManifest(
manifestUrl: string = VERSIONS_MANIFEST_URL,
): Promise<ManifestVersion[]> {
const cachedVersions = cachedManifestData.get(manifestUrl);
if (cachedVersions !== undefined) {
core.debug(`Using cached manifest data from ${manifestUrl}`);
return cachedVersions;
}
core.info(`Fetching manifest data from ${manifestUrl} ...`);
const response = await fetch(manifestUrl, {});
if (!response.ok) {
throw new Error(
`Failed to fetch manifest data: ${response.status} ${response.statusText}`,
);
}
const body = await response.text();
const versions = parseManifest(body, manifestUrl);
cachedManifestData.set(manifestUrl, versions);
return versions;
}
export function parseManifest(
data: string,
sourceDescription: string,
): ManifestVersion[] {
const trimmed = data.trim();
if (trimmed === "") {
throw new Error(`Manifest at ${sourceDescription} is empty.`);
}
if (trimmed.startsWith("[")) {
throw new Error(
`Legacy JSON array manifests are no longer supported in ${sourceDescription}. Use the astral-sh/versions manifest format instead.`,
);
}
const versions: ManifestVersion[] = [];
for (const [index, line] of data.split("\n").entries()) {
const record = line.trim();
if (record === "") {
continue;
}
let parsed: unknown;
try {
parsed = JSON.parse(record);
} catch (error) {
throw new Error(
`Failed to parse manifest data from ${sourceDescription} at line ${index + 1}: ${(error as Error).message}`,
);
}
if (!isManifestVersion(parsed)) {
throw new Error(
`Invalid manifest record in ${sourceDescription} at line ${index + 1}.`,
);
}
versions.push(parsed);
}
if (versions.length === 0) {
throw new Error(`No manifest data found in ${sourceDescription}.`);
}
return versions;
}
export async function getLatestVersion(
manifestUrl: string = VERSIONS_MANIFEST_URL,
): Promise<string> {
const versions = await fetchManifest(manifestUrl);
const [firstVersion, ...remainingVersions] = versions.map(
(versionData) => versionData.version,
);
if (firstVersion === undefined) {
throw new Error("No versions found in manifest data");
}
const latestVersion = remainingVersions.reduce(
(latest, current) => (semver.gt(current, latest) ? current : latest),
firstVersion,
);
core.debug(`Latest version from manifest: ${latestVersion}`);
return latestVersion;
}
export async function getAllVersions(
manifestUrl: string = VERSIONS_MANIFEST_URL,
): Promise<string[]> {
const versions = await fetchManifest(manifestUrl);
return versions.map((versionData) => versionData.version);
}
export async function getArtifact(
version: string,
arch: string,
platform: string,
manifestUrl: string = VERSIONS_MANIFEST_URL,
): Promise<ArtifactResult | undefined> {
const versions = await fetchManifest(manifestUrl);
const versionData = versions.find(
(candidate) => candidate.version === version,
);
if (!versionData) {
core.debug(`Version ${version} not found in manifest ${manifestUrl}`);
return undefined;
}
const targetPlatform = `${arch}-${platform}`;
const matchingArtifacts = versionData.artifacts.filter(
(candidate) => candidate.platform === targetPlatform,
);
if (matchingArtifacts.length === 0) {
core.debug(
`Artifact for ${targetPlatform} not found in version ${version}. Available platforms: ${versionData.artifacts
.map((candidate) => candidate.platform)
.join(", ")}`,
);
return undefined;
}
const artifact = selectDefaultVariant(
matchingArtifacts,
`Multiple artifacts found for ${targetPlatform} in version ${version}`,
);
return {
archiveFormat: artifact.archive_format,
checksum: artifact.sha256,
downloadUrl: artifact.url,
};
}
export function clearManifestCache(manifestUrl?: string): void {
if (manifestUrl === undefined) {
cachedManifestData.clear();
return;
}
cachedManifestData.delete(manifestUrl);
}
function isManifestVersion(value: unknown): value is ManifestVersion {
if (!isRecord(value)) {
return false;
}
if (typeof value.version !== "string" || !Array.isArray(value.artifacts)) {
return false;
}
return value.artifacts.every(isManifestArtifact);
}
function isManifestArtifact(value: unknown): value is ManifestArtifact {
if (!isRecord(value)) {
return false;
}
const variantIsValid =
typeof value.variant === "string" || value.variant === undefined;
return (
typeof value.archive_format === "string" &&
typeof value.platform === "string" &&
typeof value.sha256 === "string" &&
typeof value.url === "string" &&
variantIsValid
);
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
}

View File

@@ -1,169 +0,0 @@
import * as core from "@actions/core";
import * as semver from "semver";
import { fetch } from "../utils/fetch";
import {
clearLegacyManifestWarnings,
type ManifestEntry,
parseLegacyManifestEntries,
} from "./legacy-version-manifest";
import { selectDefaultVariant } from "./variant-selection";
import { type NdjsonVersion, parseVersionData } from "./versions-client";
export interface ManifestArtifact {
downloadUrl: string;
checksum?: string;
archiveFormat?: string;
}
const cachedManifestEntries = new Map<string, ManifestEntry[]>();
export async function getLatestKnownVersion(
manifestUrl: string,
): Promise<string> {
const versions = await getAllVersions(manifestUrl);
const latestVersion = versions.reduce((latest, current) =>
semver.gt(current, latest) ? current : latest,
);
return latestVersion;
}
export async function getAllVersions(manifestUrl: string): Promise<string[]> {
const manifestEntries = await getManifestEntries(manifestUrl);
return [...new Set(manifestEntries.map((entry) => entry.version))];
}
export async function getManifestArtifact(
manifestUrl: string,
version: string,
arch: string,
platform: string,
): Promise<ManifestArtifact | undefined> {
const manifestEntries = await getManifestEntries(manifestUrl);
const entry = selectManifestEntry(
manifestEntries,
manifestUrl,
version,
arch,
platform,
);
if (!entry) {
return undefined;
}
return {
archiveFormat: entry.archiveFormat,
checksum: entry.checksum,
downloadUrl: entry.downloadUrl,
};
}
export function clearManifestCache(): void {
cachedManifestEntries.clear();
clearLegacyManifestWarnings();
}
async function getManifestEntries(
manifestUrl: string,
): Promise<ManifestEntry[]> {
const cachedEntries = cachedManifestEntries.get(manifestUrl);
if (cachedEntries !== undefined) {
core.debug(`Using cached manifest-file from: ${manifestUrl}`);
return cachedEntries;
}
core.info(`Fetching manifest-file from: ${manifestUrl}`);
const response = await fetch(manifestUrl, {});
if (!response.ok) {
throw new Error(
`Failed to fetch manifest-file: ${response.status} ${response.statusText}`,
);
}
const data = await response.text();
const parsedEntries = parseManifestEntries(data, manifestUrl);
cachedManifestEntries.set(manifestUrl, parsedEntries);
return parsedEntries;
}
function parseManifestEntries(
data: string,
manifestUrl: string,
): ManifestEntry[] {
const trimmed = data.trim();
if (trimmed === "") {
throw new Error(`manifest-file at ${manifestUrl} is empty.`);
}
const parsedAsJson = tryParseJson(trimmed);
if (Array.isArray(parsedAsJson)) {
return parseLegacyManifestEntries(parsedAsJson, manifestUrl);
}
const versions = parseVersionData(trimmed, manifestUrl);
return mapNdjsonVersionsToManifestEntries(versions, manifestUrl);
}
function mapNdjsonVersionsToManifestEntries(
versions: NdjsonVersion[],
manifestUrl: string,
): ManifestEntry[] {
const manifestEntries: ManifestEntry[] = [];
for (const versionData of versions) {
for (const artifact of versionData.artifacts) {
const [arch, ...platformParts] = artifact.platform.split("-");
if (arch === undefined || platformParts.length === 0) {
throw new Error(
`Invalid artifact platform '${artifact.platform}' in manifest-file ${manifestUrl}.`,
);
}
manifestEntries.push({
arch,
archiveFormat: artifact.archive_format,
checksum: artifact.sha256,
downloadUrl: artifact.url,
platform: platformParts.join("-"),
variant: artifact.variant,
version: versionData.version,
});
}
}
return manifestEntries;
}
function selectManifestEntry(
manifestEntries: ManifestEntry[],
manifestUrl: string,
version: string,
arch: string,
platform: string,
): ManifestEntry | undefined {
const matches = manifestEntries.filter(
(candidate) =>
candidate.version === version &&
candidate.arch === arch &&
candidate.platform === platform,
);
if (matches.length === 0) {
return undefined;
}
return selectDefaultVariant(
matches,
`manifest-file ${manifestUrl} contains multiple artifacts for version ${version}, arch ${arch}, platform ${platform}`,
);
}
function tryParseJson(value: string): unknown {
try {
return JSON.parse(value);
} catch {
return undefined;
}
}

View File

@@ -1,191 +0,0 @@
import * as core from "@actions/core";
import { VERSIONS_NDJSON_URL } from "../utils/constants";
import { fetch } from "../utils/fetch";
import { selectDefaultVariant } from "./variant-selection";
export interface NdjsonArtifact {
platform: string;
variant?: string;
url: string;
archive_format: string;
sha256: string;
}
export interface NdjsonVersion {
version: string;
artifacts: NdjsonArtifact[];
}
export interface ArtifactResult {
url: string;
sha256: string;
archiveFormat: string;
}
const cachedVersionData = new Map<string, NdjsonVersion[]>();
export async function fetchVersionData(
url: string = VERSIONS_NDJSON_URL,
): Promise<NdjsonVersion[]> {
const cachedVersions = cachedVersionData.get(url);
if (cachedVersions !== undefined) {
core.debug(`Using cached NDJSON version data from ${url}`);
return cachedVersions;
}
core.info(`Fetching version data from ${url} ...`);
const response = await fetch(url, {});
if (!response.ok) {
throw new Error(
`Failed to fetch version data: ${response.status} ${response.statusText}`,
);
}
const body = await response.text();
const versions = parseVersionData(body, url);
cachedVersionData.set(url, versions);
return versions;
}
export function parseVersionData(
data: string,
sourceDescription: string,
): NdjsonVersion[] {
const versions: NdjsonVersion[] = [];
for (const [index, line] of data.split("\n").entries()) {
const trimmed = line.trim();
if (trimmed === "") {
continue;
}
let parsed: unknown;
try {
parsed = JSON.parse(trimmed);
} catch (error) {
throw new Error(
`Failed to parse version data from ${sourceDescription} at line ${index + 1}: ${(error as Error).message}`,
);
}
if (!isNdjsonVersion(parsed)) {
throw new Error(
`Invalid NDJSON record in ${sourceDescription} at line ${index + 1}.`,
);
}
versions.push(parsed);
}
if (versions.length === 0) {
throw new Error(`No version data found in ${sourceDescription}.`);
}
return versions;
}
export async function getLatestVersion(): Promise<string> {
const versions = await fetchVersionData();
const latestVersion = versions[0]?.version;
if (!latestVersion) {
throw new Error("No versions found in NDJSON data");
}
core.debug(`Latest version from NDJSON: ${latestVersion}`);
return latestVersion;
}
export async function getAllVersions(): Promise<string[]> {
const versions = await fetchVersionData();
return versions.map((versionData) => versionData.version);
}
export async function getArtifact(
version: string,
arch: string,
platform: string,
): Promise<ArtifactResult | undefined> {
const versions = await fetchVersionData();
const versionData = versions.find(
(candidate) => candidate.version === version,
);
if (!versionData) {
core.debug(`Version ${version} not found in NDJSON data`);
return undefined;
}
const targetPlatform = `${arch}-${platform}`;
const matchingArtifacts = versionData.artifacts.filter(
(candidate) => candidate.platform === targetPlatform,
);
if (matchingArtifacts.length === 0) {
core.debug(
`Artifact for ${targetPlatform} not found in version ${version}. Available platforms: ${versionData.artifacts
.map((candidate) => candidate.platform)
.join(", ")}`,
);
return undefined;
}
const artifact = selectArtifact(matchingArtifacts, version, targetPlatform);
return {
archiveFormat: artifact.archive_format,
sha256: artifact.sha256,
url: artifact.url,
};
}
export function clearCache(url?: string): void {
if (url === undefined) {
cachedVersionData.clear();
return;
}
cachedVersionData.delete(url);
}
function selectArtifact(
artifacts: NdjsonArtifact[],
version: string,
targetPlatform: string,
): NdjsonArtifact {
return selectDefaultVariant(
artifacts,
`Multiple artifacts found for ${targetPlatform} in version ${version}`,
);
}
function isNdjsonVersion(value: unknown): value is NdjsonVersion {
if (!isRecord(value)) {
return false;
}
if (typeof value.version !== "string" || !Array.isArray(value.artifacts)) {
return false;
}
return value.artifacts.every(isNdjsonArtifact);
}
function isNdjsonArtifact(value: unknown): value is NdjsonArtifact {
if (!isRecord(value)) {
return false;
}
const variantIsValid =
typeof value.variant === "string" || value.variant === undefined;
return (
typeof value.archive_format === "string" &&
typeof value.platform === "string" &&
typeof value.sha256 === "string" &&
typeof value.url === "string" &&
variantIsValid
);
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
}

View File

@@ -4,8 +4,7 @@ import * as core from "@actions/core";
import * as exec from "@actions/exec"; import * as exec from "@actions/exec";
import { restoreCache } from "./cache/restore-cache"; import { restoreCache } from "./cache/restore-cache";
import { import {
downloadVersionFromManifest, downloadVersion,
downloadVersionFromNdjson,
resolveVersion, resolveVersion,
tryGetFromToolCache, tryGetFromToolCache,
} from "./download/download-version"; } from "./download/download-version";
@@ -132,7 +131,7 @@ async function setupUv(
checkSum: string | undefined, checkSum: string | undefined,
githubToken: string, githubToken: string,
): Promise<{ uvDir: string; version: string }> { ): Promise<{ uvDir: string; version: string }> {
const resolvedVersion = await determineVersion(manifestFile); const resolvedVersion = await determineVersion();
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion); const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
if (toolCacheResult.installedPath) { if (toolCacheResult.installedPath) {
core.info(`Found uv in tool-cache for ${toolCacheResult.version}`); core.info(`Found uv in tool-cache for ${toolCacheResult.version}`);
@@ -142,36 +141,34 @@ async function setupUv(
}; };
} }
const downloadVersionResult = const downloadResult = await downloadVersion(
manifestFile !== undefined platform,
? await downloadVersionFromManifest( arch,
manifestFile, resolvedVersion,
platform, checkSum,
arch, githubToken,
resolvedVersion, manifestFile,
checkSum, );
githubToken,
)
: await downloadVersionFromNdjson(
platform,
arch,
resolvedVersion,
checkSum,
githubToken,
);
return { return {
uvDir: downloadVersionResult.cachedToolDir, uvDir: downloadResult.cachedToolDir,
version: downloadVersionResult.version, version: downloadResult.version,
}; };
} }
async function determineVersion( async function determineVersion(): Promise<string> {
manifestFile: string | undefined, return await resolveVersion(
): Promise<string> { getRequestedVersion(),
manifestFile,
resolutionStrategy,
);
}
function getRequestedVersion(): string {
if (versionInput !== "") { if (versionInput !== "") {
return await resolveVersion(versionInput, manifestFile, resolutionStrategy); return versionInput;
} }
if (versionFileInput !== "") { if (versionFileInput !== "") {
const versionFromFile = getUvVersionFromFile(versionFileInput); const versionFromFile = getUvVersionFromFile(versionFileInput);
if (versionFromFile === undefined) { if (versionFromFile === undefined) {
@@ -179,28 +176,23 @@ async function determineVersion(
`Could not determine uv version from file: ${versionFileInput}`, `Could not determine uv version from file: ${versionFileInput}`,
); );
} }
return await resolveVersion( return versionFromFile;
versionFromFile,
manifestFile,
resolutionStrategy,
);
} }
const versionFromUvToml = getUvVersionFromFile( const versionFromUvToml = getUvVersionFromFile(
`${workingDirectory}${path.sep}uv.toml`, `${workingDirectory}${path.sep}uv.toml`,
); );
const versionFromPyproject = getUvVersionFromFile( const versionFromPyproject = getUvVersionFromFile(
`${workingDirectory}${path.sep}pyproject.toml`, `${workingDirectory}${path.sep}pyproject.toml`,
); );
if (versionFromUvToml === undefined && versionFromPyproject === undefined) { if (versionFromUvToml === undefined && versionFromPyproject === undefined) {
core.info( core.info(
"Could not determine uv version from uv.toml or pyproject.toml. Falling back to latest.", "Could not determine uv version from uv.toml or pyproject.toml. Falling back to latest.",
); );
} }
return await resolveVersion(
versionFromUvToml || versionFromPyproject || "latest", return versionFromUvToml || versionFromPyproject || "latest";
manifestFile,
resolutionStrategy,
);
} }
function addUvToPathAndOutput(cachedPath: string): void { function addUvToPathAndOutput(cachedPath: string): void {

View File

@@ -6,10 +6,10 @@ import {
updateChecksums, updateChecksums,
} from "./download/checksum/update-known-checksums"; } from "./download/checksum/update-known-checksums";
import { import {
fetchVersionData, fetchManifest,
getLatestVersion, getLatestVersion,
type NdjsonVersion, type ManifestVersion,
} from "./download/versions-client"; } from "./download/manifest";
const VERSION_IN_CHECKSUM_KEY_PATTERN = const VERSION_IN_CHECKSUM_KEY_PATTERN =
/-(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)$/; /-(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)$/;
@@ -32,8 +32,8 @@ async function run(): Promise<void> {
return; return;
} }
const versions = await fetchVersionData(); const versions = await fetchManifest();
const checksumEntries = extractChecksumsFromNdjson(versions); const checksumEntries = extractChecksumsFromManifest(versions);
await updateChecksums(checksumFilePath, checksumEntries); await updateChecksums(checksumFilePath, checksumEntries);
core.setOutput("latest-version", latestVersion); core.setOutput("latest-version", latestVersion);
@@ -61,8 +61,8 @@ function extractVersionFromChecksumKey(key: string): string | undefined {
return key.match(VERSION_IN_CHECKSUM_KEY_PATTERN)?.[1]; return key.match(VERSION_IN_CHECKSUM_KEY_PATTERN)?.[1];
} }
function extractChecksumsFromNdjson( function extractChecksumsFromManifest(
versions: NdjsonVersion[], versions: ManifestVersion[],
): ChecksumEntry[] { ): ChecksumEntry[] {
const checksums: ChecksumEntry[] = []; const checksums: ChecksumEntry[] = [];

View File

@@ -1,7 +1,7 @@
export const TOOL_CACHE_NAME = "uv"; export const TOOL_CACHE_NAME = "uv";
export const STATE_UV_PATH = "uv-path"; export const STATE_UV_PATH = "uv-path";
export const STATE_UV_VERSION = "uv-version"; export const STATE_UV_VERSION = "uv-version";
export const VERSIONS_NDJSON_URL = export const VERSIONS_MANIFEST_URL =
"https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson"; "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
/** GitHub Releases URL prefix for uv artifacts. */ /** GitHub Releases URL prefix for uv artifacts. */