Compare commits

...
7 Commits
Author SHA1 Message Date
68559e99cc Use Astral mirror for version manifests with GitHub fallback (#1119)
Amp-Thread-ID:
https://ampcode.com/threads/T-01a1822a-68da-7125-9e7d-16e038ab0840

Closes: #1118

Co-authored-by: Amp <amp@ampcode.com>
2026-10-28 15:09:55 +01:00
0192b69518 chore: update known checksums for 0.13.6 (#1117)
chore: update known checksums for 0.13.6

Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2026-10-27 11:55:43 +01:00
2f29784424 docs: use JSDoc for compatible release specifier comment (#1113)
Amp-Thread-ID:
https://ampcode.com/threads/T-01a17443-b5b9-703c-8877-780650eae403

Co-authored-by: Amp <amp@ampcode.com>
2026-10-26 08:49:11 +01:00
9c7332190c fix: allow whitespace in uv requirement specifiers (#1112)
## Summary

When the uv version is read from dependencies (`requirements.txt`, or
`project.dependencies` / `optional-dependencies` / `dependency-groups`
in `pyproject.toml` via `version-file`), the specifier was matched with
`/^uv([=<>~!]+\S*)/`. PEP 508 allows whitespace around operators and
after commas, and those valid forms were misread:

| dependency | before | after |
|---|---|---|
| `uv >= 0.5.0` | not found, latest uv installed | `>=0.5.0` |
| `uv == 0.11.20` | not found, latest uv installed | `==0.11.20` |
| `uv>=0.5.0, <0.6.0` | `>=0.5.0,`, fails with `No version found for
>=0.5.0,` | `>=0.5.0,<0.6.0` |

The regex now allows whitespace around operators and between
comma-separated clauses, and strips it from the result. Inputs that
worked before give the same result, including inline `--hash=` options,
trailing ` # comments`, the `\` continuation lines from `uv pip compile
--generate-hashes`, and names that only start with `uv` (`uvicorn`,
`uv-build`).

## Test plan

- Added cases for spaced operators, spaced clauses, inline `--hash` and
trailing comments. The four whitespace cases failed before the change.
- `npm run all` on Ubuntu (WSL) with Node 24.19.0: build, Biome (no
fixes), packaging, and 165 tests across 15 suites pass. The rebuilt
`dist/setup/index.cjs` only differs in the changed line.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 08:37:03 +01:00
80fbe0140c fix: resolve ~= specifiers with PEP 440 semantics (#1111)
## Summary

`~=` is the PEP 440 compatible release operator, but the resolver tries
`semver.validRange()` first, and semver accepts `~=` as a tilde range:

| specifier | semver | PEP 440 |
|---|---|---|
| `~=0.9` | `>=0.9.0 <0.10.0` | `>=0.9, ==0.*` |

So with the default `highest` strategy, `version: "~=0.9"` (or
`required-version = "~=0.9"` picked up through `version-file`) installs
the highest 0.9.x instead of the highest 0.x. The same happens with
`manifest-file`, where `tc.evaluateVersions` is semver-based.

This skips the semver evaluation for specifiers containing `~=`, so they
are only evaluated with `@renovatebot/pep440`. No semver range
legitimately uses `~=`.

Notes:

- Only a bare two-segment `~=X.Y` resolved incorrectly. `~=X.Y.Z` gives
the same result in both, and compound specifiers like `~=0.9, !=0.9.3`
were already rejected by semver and fell through to PEP 440.
- `minSatisfying` gets the same check for consistency. The lower bound
is the same under both interpretations, so `lowest` didn't produce wrong
results before.
- A single-segment `~=1` is invalid PEP 440. semver used to resolve it
to 1.x; it now fails with `No version found for ~=1`, same as other
invalid specifiers.

## Test plan

- Added tests for `~=0.9` with the default manifest and with
`manifest-file`. Both returned `0.9.26` instead of `0.10.2` before the
change.
- `npm run all` on Ubuntu (WSL) with Node 24.19.0: build, Biome (no
fixes), packaging, and 161 tests across 15 suites pass. The rebuilt
`dist/setup/index.cjs` only differs in the changed lines.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:39:29 +01:00
36b7b57007 fix: only report a saved cache when saving succeeded (#1110)
## Summary

The post step logs `uv cache saved with key: ...` (and `Python cache
saved with key: ...`) even when the save failed. The log in #769 shows
it right after `Warning: Failed to save: ...`:

```
Warning: Failed to save: "C:\Program failed with error: The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2
uv cache saved with key: setup-uv-2-x86_64-pc-windows-msvc-windows-11-3.12.12-pruned-...
```

`@actions/cache`'s `saveCache` doesn't throw for these failures. It logs
them and returns `-1`, and `saveCacheToKey` ignored the return value.
This now checks for `-1` before logging, which is the same check the
`actions/cache` save step uses (`if (cacheId != -1) core.info("Cache
saved with key: ...")`). `@actions/cache` already logs the reason, so
nothing else is logged on failure, and the exit code stays the same.

This only changes the log line. It doesn't address the underlying
tar/gzip failure in #769. One limitation: with the legacy (v1) cache
service, an upload that fails after the cache was reserved still returns
the reserved id, so that one case is still reported as saved. That's on
the `@actions/cache` side and affects `actions/cache` the same way.

Related to #769

## Test plan

- Added `__tests__/cache/save-cache.test.ts`. The `-1` case fails before
the change and passes after it.
- `npm run all` on Ubuntu (WSL) with Node 24.19.0 / npm 11.17.0: build,
Biome (no fixes), packaging, and all 161 tests across 16 suites pass.
The regenerated `dist/save-cache/index.cjs` only differs in the changed
lines.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:38:39 +01:00
56618cab7a docs: update version references to v10.3.2 (#1104)
Update `uses: astral-sh/setup-uv@...` references in documentation to
`07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2`.

Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2026-10-22 11:25:32 +02:00
18 changed files with 385 additions and 65 deletions
+9 -9
View File
@@ -27,7 +27,7 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
```yaml
- name: Install the latest version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
```
If you do not specify a version, this action will look for a [required-version](https://docs.astral.sh/uv/reference/settings/#required-version)
@@ -43,7 +43,7 @@ Have a look under [Advanced Configuration](#advanced-configuration) for detailed
```yaml
- name: Install uv with all available options
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
# The version of uv to install, e.g., "0.5.0", "latest", or "latest-known" (default: searches for version in config files, then latest)
version: ""
@@ -161,7 +161,7 @@ python 3.13
```
```yaml
- uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version-file: ".tool-versions"
```
@@ -172,7 +172,7 @@ a warning.
```yaml
- name: Install the latest version of uv and set the python version to 3.13t
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
python-version: 3.13t
- run: uv pip install --python=3.13t pip
@@ -190,7 +190,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
python-version: ${{ matrix.python-version }}
- name: Test with python ${{ matrix.python-version }}
@@ -226,7 +226,7 @@ It also controls where [the venv gets created](#activate-environment), unless `v
```yaml
- name: Install uv based on the config files in the working-directory
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
working-directory: my/subproject/dir
```
@@ -268,7 +268,7 @@ For example:
- name: Checkout the repository
uses: actions/checkout@main
- name: Install the latest version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
- name: Test
@@ -280,7 +280,7 @@ To install a specific version of Python, use
```yaml
- name: Install the latest version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
- name: Install Python 3.12
@@ -299,7 +299,7 @@ output:
uses: actions/checkout@main
- name: Install the default version of uv
id: setup-uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
- name: Print the installed version
run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"
```
+87
View File
@@ -0,0 +1,87 @@
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
afterAll,
beforeEach,
describe,
expect,
it,
jest,
} from "@jest/globals";
import { CacheLocalSource, type SetupInputs } from "../../src/utils/inputs";
import { createSetupInputs } from "../helpers/setup-inputs";
const mockSaveCache = jest.fn<() => Promise<number>>();
const mockInfo = jest.fn();
const mockLoadInputs = jest.fn<() => SetupInputs>(() =>
createSetupInputs({ enableCache: false }),
);
const state: Record<string, string> = {};
jest.unstable_mockModule("@actions/cache", () => ({
saveCache: mockSaveCache,
}));
jest.unstable_mockModule("@actions/core", () => ({
getState: jest.fn((name: string) => state[name] ?? ""),
setFailed: jest.fn(),
}));
jest.unstable_mockModule("../../src/utils/inputs", () => ({
loadInputs: mockLoadInputs,
}));
jest.unstable_mockModule("../../src/utils/logging", () => ({
info: mockInfo,
warning: jest.fn(),
}));
jest.spyOn(process, "exit").mockImplementation((() => undefined) as never);
const { run } = await import("../../src/save-cache");
const cacheDir = mkdtempSync(join(tmpdir(), "setup-uv-save-cache-"));
const cacheKey = "setup-uv-2-x86_64-unknown-linux-gnu-ubuntu-24.04-3.12-hash";
function infoMessages(): string[] {
return mockInfo.mock.calls.map(([msg]) => msg as string);
}
beforeEach(() => {
delete process.env.UV_CACHE_DIR;
state["cache-key"] = cacheKey;
state["cache-matched-key"] = "";
mockLoadInputs.mockReturnValue(
createSetupInputs({
cacheLocalPath: { path: cacheDir, source: CacheLocalSource.Input },
}),
);
});
afterAll(() => {
rmSync(cacheDir, { force: true, recursive: true });
});
describe("saveCache", () => {
it("reports the saved key when the cache is saved", async () => {
mockSaveCache.mockResolvedValue(42);
await run();
expect(mockSaveCache).toHaveBeenCalledWith([cacheDir], cacheKey);
expect(infoMessages()).toContain(`uv cache saved with key: ${cacheKey}`);
});
it("does not report the cache as saved when saving fails", async () => {
// @actions/cache logs the failure itself and returns -1
mockSaveCache.mockResolvedValue(-1);
await run();
expect(mockSaveCache).toHaveBeenCalledWith([cacheDir], cacheKey);
expect(infoMessages()).not.toContain(
`uv cache saved with key: ${cacheKey}`,
);
});
});
+23 -1
View File
@@ -146,6 +146,28 @@ describe("download-version", () => {
expect(mockGetAllVersions).not.toHaveBeenCalled();
});
it("resolves ~= with PEP 440 compatible release semantics", async () => {
mockGetFirstMatchingVersion.mockImplementation(
(predicate: (version: string) => boolean) =>
["1.0.0", "0.10.2", "0.9.26"].find(predicate),
);
const version = await resolveVersion("~=0.9", undefined);
expect(version).toBe("0.10.2");
});
it("resolves ~= with PEP 440 compatible release semantics from manifest-file", async () => {
mockGetAllVersions.mockResolvedValue(["1.0.0", "0.10.2", "0.9.26"]);
const version = await resolveVersion(
"~=0.9",
"https://example.com/custom.ndjson",
);
expect(version).toBe("0.10.2");
});
it("treats == exact pins as explicit versions", async () => {
const version = await resolveVersion("==0.9.26", undefined);
@@ -220,7 +242,7 @@ describe("download-version", () => {
"token",
),
).rejects.toThrow(
"Could not find artifact for version 0.9.26, arch x86_64, platform unknown-linux-gnu in https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson .",
"Could not find artifact for version 0.9.26, arch x86_64, platform unknown-linux-gnu in https://releases.astral.sh/github/versions/main/v1/uv.ndjson .",
);
expect(mockDownloadTool).not.toHaveBeenCalled();
+73 -1
View File
@@ -96,6 +96,78 @@ describe("manifest", () => {
expect(versions).toHaveLength(2);
expect(versions[0]?.version).toBe("0.9.26");
expect(versions[1]?.version).toBe("0.9.25");
expect(mockFetch.mock.calls.map(([url]) => url)).toEqual([
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson",
]);
});
it("falls back to GitHub after mirror network retries are exhausted", async () => {
jest.useFakeTimers();
mockFetch
.mockRejectedValueOnce(new Error("mirror unavailable"))
.mockRejectedValueOnce(new Error("mirror unavailable"))
.mockRejectedValueOnce(new Error("mirror unavailable"))
.mockResolvedValueOnce(
createMockResponse(true, 200, "OK", sampleManifestResponse),
);
const result = fetchManifest();
await jest.runAllTimersAsync();
await expect(result).resolves.toEqual([
expect.objectContaining({ version: "0.9.26" }),
expect.objectContaining({ version: "0.9.25" }),
]);
expect(mockFetch.mock.calls.map(([url]) => url)).toEqual([
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson",
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson",
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson",
"https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson",
]);
await expect(getLatestVersion()).resolves.toBe("0.9.26");
expect(mockFetch).toHaveBeenCalledTimes(4);
});
it.each([404, 429, 503])(
"falls back to a streaming GitHub manifest on mirror HTTP %s",
async (status) => {
mockFetch
.mockResolvedValueOnce(createMockResponse(false, status, "Error", ""))
.mockResolvedValueOnce(
createStreamingMockResponse([`${sampleManifestResponse}\n`]),
);
await expect(getLatestVersion()).resolves.toBe("0.9.26");
await expect(
getArtifact("0.9.26", "aarch64", "apple-darwin"),
).resolves.toEqual({
archiveFormat: "tar.gz",
checksum:
"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f",
downloadUrl:
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz",
});
expect(mockFetch.mock.calls.map(([url]) => url)).toEqual([
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson",
"https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson",
]);
},
);
it("does not fall back from a custom manifest", async () => {
mockFetch.mockResolvedValue(
createMockResponse(false, 503, "Service Unavailable", ""),
);
await expect(
fetchManifest("https://example.com/custom.ndjson"),
).rejects.toThrow(
"Failed to fetch manifest data: 503 Service Unavailable",
);
expect(mockFetch.mock.calls.map(([url]) => url)).toEqual([
"https://example.com/custom.ndjson",
]);
});
it("retries network failures", async () => {
@@ -123,7 +195,7 @@ describe("manifest", () => {
await jest.runAllTimersAsync();
await result;
expect(mockFetch).toHaveBeenCalledTimes(MANIFEST_FETCH_ATTEMPTS);
expect(mockFetch).toHaveBeenCalledTimes(MANIFEST_FETCH_ATTEMPTS * 2);
});
it("throws on a failed fetch", async () => {
@@ -35,3 +35,14 @@ test("strips PEP 508 markers from requirements dependencies", () => {
expect(parsedVersion).toBe("==0.11.20");
});
test.each([
["uv >= 0.5.0", ">=0.5.0"],
["uv == 0.11.20", "==0.11.20"],
["uv>=0.5.0, <0.6.0", ">=0.5.0,<0.6.0"],
["uv >= 0.5.0 , < 0.6.0", ">=0.5.0,<0.6.0"],
["uv==0.11.20 --hash=sha256:abc", "==0.11.20"],
["uv==0.11.20 # pinned for CI", "==0.11.20"],
])("allows whitespace in the uv specifier %s", (dependency, expected) => {
expect(getUvVersionFromRequirementsText(dependency)).toBe(expected);
});
Generated Vendored
+4 -2
View File
@@ -66671,8 +66671,10 @@ async function saveCacheToKey(cacheKey, cachePath, stateKey, cacheName) {
return;
}
info2(`Including ${cacheName} path: ${cachePath}`);
await saveCache2([cachePath], cacheKey);
info2(`${cacheName} saved with key: ${cacheKey}`);
const cacheId = await saveCache2([cachePath], cacheKey);
if (cacheId !== -1) {
info2(`${cacheName} saved with key: ${cacheKey}`);
}
}
__name(saveCacheToKey, "saveCacheToKey");
run();
Generated Vendored
+40 -5
View File
@@ -94499,7 +94499,8 @@ function _getGlobal(key, defaultValue) {
var TOOL_CACHE_NAME = "uv";
var STATE_UV_PATH = "uv-path";
var STATE_UV_VERSION = "uv-version";
var VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
var VERSIONS_MANIFEST_URL = "https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
var GITHUB_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 ASTRAL_MIRROR_PREFIX = "https://releases.astral.sh/github/uv/releases/download/";
@@ -94509,6 +94510,24 @@ var fs10 = __toESM(require("node:fs"), 1);
// src/download/checksum/known-checksums.json
var known_checksums_default = {
"aarch64-apple-darwin-0.13.6": "60fbd5c8a1ed681845eea28d9d622fcde03c51e91a43465b64a1e17db1ed3472",
"aarch64-pc-windows-msvc-0.13.6": "c2426c0c8e28b53d8c440e47a18d96ad4db51e159866c0e81435b196d7f0081c",
"aarch64-unknown-linux-gnu-0.13.6": "229e194255c7958d86d56e8790d969a6f74736592133f0dfd0076f754c642c1d",
"aarch64-unknown-linux-musl-0.13.6": "819692e404d23e5aae6bc44c0e260f1f5492fd1910ab4693b2c650f926dbe800",
"arm-unknown-linux-musleabihf-0.13.6": "57ac0f7c04deb42c5d686b4eeeef555c442db6ffea16fe4cbd7adb0384403794",
"armv7-unknown-linux-gnueabihf-0.13.6": "d00cd4949c4524c934afcfee1aedfa9d337cf4e43be4d6b692ad8d74d0a65562",
"armv7-unknown-linux-musleabihf-0.13.6": "b215398c886e8cc2cfa282fe346c02025957f8633b75a3d4fd848e0adda4eddd",
"i686-pc-windows-msvc-0.13.6": "32ceb64db231cbedfd499f7654c72e4c0b564f2846f9e76c0a4a7b2d03d7e67c",
"i686-unknown-linux-gnu-0.13.6": "665ea831c38d342900950e606beb2ccc37b7ba0fcefc37b814eb4b076305f2b6",
"i686-unknown-linux-musl-0.13.6": "de3a015c4b0fce63c178ae4fa95c94c873adfd92fa1e258c6a2a94e529812629",
"powerpc64le-unknown-linux-gnu-0.13.6": "3b2847185ec2946fcc928500efef7e3e74c255d3be6f2cb435081a84885d8c6c",
"riscv64gc-unknown-linux-gnu-0.13.6": "517052603ed46483b59d8875c9c61a577946b8f493c73e4339e45e7b119171d0",
"riscv64gc-unknown-linux-musl-0.13.6": "659a95dc6aee3ecf86742a08d8ca6c6261422121cbd41decc0042f5a71af6305",
"s390x-unknown-linux-gnu-0.13.6": "fb56d731308aa5c7718059d71afcb14d9a933a974997cee3d4eb5d06fc462a4b",
"x86_64-apple-darwin-0.13.6": "63ba17fdda55ad1a230d4b37fc6017ffa10c23688c83818bd3bfdf914c652a02",
"x86_64-pc-windows-msvc-0.13.6": "a2a8820d5eea32f08ef467ef3b7f66883a9b076d5737a2fc2fbb5f458d1bb50f",
"x86_64-unknown-linux-gnu-0.13.6": "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645",
"x86_64-unknown-linux-musl-0.13.6": "5d61f26b6c7213779eda90edc6971ea6b0b796bfb8d49a574c8ad69b59838548",
"aarch64-apple-darwin-0.13.5": "743f85035a1996ecb350659e01cd9faea9709829be09b1b4b03c73eaf3c9cd73",
"aarch64-pc-windows-msvc-0.13.5": "09f47edf90726084a70f9426f6e3ca4f46e9bf7cbf23b1716ec64d60b055fae3",
"aarch64-unknown-linux-gnu-0.13.5": "4bb69cf95ed13f23713bb7bc09f241896ea0c75b7c557e615a20604b82f9c403",
@@ -100287,6 +100306,19 @@ async function getArtifact(version3, arch3, platform2, manifestUrl = VERSIONS_MA
};
}
async function fetchManifestResponse(manifestUrl) {
try {
return await fetchManifestResponseFromUrl(manifestUrl);
} catch (error2) {
if (manifestUrl !== VERSIONS_MANIFEST_URL) {
throw error2;
}
info2(
`Failed to fetch manifest from Astral mirror, falling back to GitHub: ${error2.message}`
);
return await fetchManifestResponseFromUrl(GITHUB_VERSIONS_MANIFEST_URL);
}
}
async function fetchManifestResponseFromUrl(manifestUrl) {
let response;
for (let attempt = 1; attempt <= MANIFEST_FETCH_ATTEMPTS; attempt++) {
info2(`Fetching manifest data from ${manifestUrl} ...`);
@@ -101579,7 +101611,7 @@ function getUvVersionFromAllDependencies(allDependencies) {
}
function getUvVersionFromDependency(dependency) {
const dependencyWithoutMarker = dependency.split(";", 1)[0]?.trim();
return dependencyWithoutMarker?.match(/^uv([=<>~!]+\S*)/)?.[1].trim();
return dependencyWithoutMarker?.match(/^uv\s*((?:[=<>~!]+\s*[^\s,]+\s*,?\s*)+)/)?.[1].replace(/\s/g, "");
}
// src/version/tool-versions-file.ts
@@ -101937,7 +101969,7 @@ async function resolveVersion(versionInput, manifestUrl, resolutionStrategy = "h
throw new Error(`No version found for ${versionInput}`);
}
async function findHighestSatisfyingVersion(versionSpecifier) {
const semverRange = semver5.validRange(versionSpecifier);
const semverRange = isCompatibleReleaseSpecifier(versionSpecifier) ? null : semver5.validRange(versionSpecifier);
if (semverRange !== null) {
const semverMatch = await getFirstMatchingVersion(
(version3) => semver5.satisfies(version3, semverRange)
@@ -101959,8 +101991,11 @@ async function findHighestSatisfyingVersion(versionSpecifier) {
}
return pep440Match;
}
function isCompatibleReleaseSpecifier(versionSpecifier) {
return versionSpecifier.includes("~=");
}
function maxSatisfying2(versions, version3) {
const maxSemver = evaluateVersions(versions, version3);
const maxSemver = isCompatibleReleaseSpecifier(version3) ? "" : evaluateVersions(versions, version3);
if (maxSemver !== "") {
debug(`Found a version that satisfies the semver range: ${maxSemver}`);
return maxSemver;
@@ -101975,7 +102010,7 @@ function maxSatisfying2(versions, version3) {
return void 0;
}
function minSatisfying3(versions, version3) {
const minSemver = semver5.minSatisfying(versions, version3);
const minSemver = isCompatibleReleaseSpecifier(version3) ? null : semver5.minSatisfying(versions, version3);
if (minSemver !== null) {
debug(`Found a version that satisfies the semver range: ${minSemver}`);
return minSemver;
+33 -1
View File
@@ -47182,6 +47182,24 @@ var semver = __toESM(require_semver(), 1);
// src/download/checksum/known-checksums.json
var known_checksums_default = {
"aarch64-apple-darwin-0.13.6": "60fbd5c8a1ed681845eea28d9d622fcde03c51e91a43465b64a1e17db1ed3472",
"aarch64-pc-windows-msvc-0.13.6": "c2426c0c8e28b53d8c440e47a18d96ad4db51e159866c0e81435b196d7f0081c",
"aarch64-unknown-linux-gnu-0.13.6": "229e194255c7958d86d56e8790d969a6f74736592133f0dfd0076f754c642c1d",
"aarch64-unknown-linux-musl-0.13.6": "819692e404d23e5aae6bc44c0e260f1f5492fd1910ab4693b2c650f926dbe800",
"arm-unknown-linux-musleabihf-0.13.6": "57ac0f7c04deb42c5d686b4eeeef555c442db6ffea16fe4cbd7adb0384403794",
"armv7-unknown-linux-gnueabihf-0.13.6": "d00cd4949c4524c934afcfee1aedfa9d337cf4e43be4d6b692ad8d74d0a65562",
"armv7-unknown-linux-musleabihf-0.13.6": "b215398c886e8cc2cfa282fe346c02025957f8633b75a3d4fd848e0adda4eddd",
"i686-pc-windows-msvc-0.13.6": "32ceb64db231cbedfd499f7654c72e4c0b564f2846f9e76c0a4a7b2d03d7e67c",
"i686-unknown-linux-gnu-0.13.6": "665ea831c38d342900950e606beb2ccc37b7ba0fcefc37b814eb4b076305f2b6",
"i686-unknown-linux-musl-0.13.6": "de3a015c4b0fce63c178ae4fa95c94c873adfd92fa1e258c6a2a94e529812629",
"powerpc64le-unknown-linux-gnu-0.13.6": "3b2847185ec2946fcc928500efef7e3e74c255d3be6f2cb435081a84885d8c6c",
"riscv64gc-unknown-linux-gnu-0.13.6": "517052603ed46483b59d8875c9c61a577946b8f493c73e4339e45e7b119171d0",
"riscv64gc-unknown-linux-musl-0.13.6": "659a95dc6aee3ecf86742a08d8ca6c6261422121cbd41decc0042f5a71af6305",
"s390x-unknown-linux-gnu-0.13.6": "fb56d731308aa5c7718059d71afcb14d9a933a974997cee3d4eb5d06fc462a4b",
"x86_64-apple-darwin-0.13.6": "63ba17fdda55ad1a230d4b37fc6017ffa10c23688c83818bd3bfdf914c652a02",
"x86_64-pc-windows-msvc-0.13.6": "a2a8820d5eea32f08ef467ef3b7f66883a9b076d5737a2fc2fbb5f458d1bb50f",
"x86_64-unknown-linux-gnu-0.13.6": "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645",
"x86_64-unknown-linux-musl-0.13.6": "5d61f26b6c7213779eda90edc6971ea6b0b796bfb8d49a574c8ad69b59838548",
"aarch64-apple-darwin-0.13.5": "743f85035a1996ecb350659e01cd9faea9709829be09b1b4b03c73eaf3c9cd73",
"aarch64-pc-windows-msvc-0.13.5": "09f47edf90726084a70f9426f6e3ca4f46e9bf7cbf23b1716ec64d60b055fae3",
"aarch64-unknown-linux-gnu-0.13.5": "4bb69cf95ed13f23713bb7bc09f241896ea0c75b7c557e615a20604b82f9c403",
@@ -52836,7 +52854,8 @@ var import_node_readline = require("node:readline");
var import_node_stream = require("node:stream");
// src/utils/constants.ts
var VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
var VERSIONS_MANIFEST_URL = "https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
var GITHUB_VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
// src/utils/fetch.ts
var import_undici2 = __toESM(require_undici2(), 1);
@@ -52908,6 +52927,19 @@ async function getLatestVersion(manifestUrl = VERSIONS_MANIFEST_URL) {
return latestVersion;
}
async function fetchManifestResponse(manifestUrl) {
try {
return await fetchManifestResponseFromUrl(manifestUrl);
} catch (error2) {
if (manifestUrl !== VERSIONS_MANIFEST_URL) {
throw error2;
}
info2(
`Failed to fetch manifest from Astral mirror, falling back to GitHub: ${error2.message}`
);
return await fetchManifestResponseFromUrl(GITHUB_VERSIONS_MANIFEST_URL);
}
}
async function fetchManifestResponseFromUrl(manifestUrl) {
let response;
for (let attempt = 1; attempt <= MANIFEST_FETCH_ATTEMPTS; attempt++) {
info2(`Fetching manifest data from ${manifestUrl} ...`);
+9 -9
View File
@@ -6,7 +6,7 @@ This document covers advanced options for configuring which version of uv to ins
```yaml
- name: Install the latest version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "latest"
```
@@ -19,7 +19,7 @@ When `manifest-file` is set, `latest-known` still selects a version from setup-u
```yaml
- name: Install the latest version of uv known to setup-uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "latest-known"
```
@@ -28,7 +28,7 @@ When `manifest-file` is set, `latest-known` still selects a version from setup-u
```yaml
- name: Install a specific version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "0.4.4"
```
@@ -41,21 +41,21 @@ to install the latest version that satisfies the range.
```yaml
- name: Install a semver range of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: ">=0.4.0"
```
```yaml
- name: Pinning a minor version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "0.4.x"
```
```yaml
- name: Install a pep440-specifier-satisfying version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: ">=0.4.25,<0.5"
```
@@ -67,7 +67,7 @@ You can change this behavior using the `resolution-strategy` input:
```yaml
- name: Install the lowest compatible version of uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: ">=0.4.0"
resolution-strategy: "lowest"
@@ -92,7 +92,7 @@ as `UV_PYTHON`. Only a single Python version is supported; multiple fallback ver
```yaml
- name: Install uv based on the version defined in pyproject.toml
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version-file: "pyproject.toml"
```
@@ -103,7 +103,7 @@ silently picking up a newer uv until the lockfile is updated.
```yaml
- name: Install uv based on the version locked in uv.lock
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version-file: "uv.lock"
```
+12 -12
View File
@@ -24,7 +24,7 @@ The computed cache key is available as the `cache-key` output:
```yaml
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
- name: Print cache key
@@ -54,7 +54,7 @@ You can optionally define a custom cache key suffix.
```yaml
- name: Enable caching and define a custom cache key suffix
id: setup-uv
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-suffix: "optional-suffix"
@@ -93,7 +93,7 @@ changes. If you use relative paths, they are relative to the working directory.
```yaml
- name: Define a cache dependency glob
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
@@ -101,7 +101,7 @@ changes. If you use relative paths, they are relative to the working directory.
```yaml
- name: Define a list of cache dependency globs
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: |
@@ -111,7 +111,7 @@ changes. If you use relative paths, they are relative to the working directory.
```yaml
- name: Define an absolute cache dependency glob
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: "/tmp/my-folder/requirements*.txt"
@@ -119,7 +119,7 @@ changes. If you use relative paths, they are relative to the working directory.
```yaml
- name: Never invalidate the cache
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: ""
@@ -132,7 +132,7 @@ By default, the cache will be restored.
```yaml
- name: Don't restore an existing cache
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
restore-cache: false
@@ -148,7 +148,7 @@ these events. Set `save-cache: true` to save the cache for all events.
```yaml
- name: Don't save the cache after the run
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
save-cache: false
@@ -174,7 +174,7 @@ It defaults to `setup-uv-cache` in the `TMP` dir, `D:\a\_temp\setup-uv-cache` on
```yaml
- name: Define a custom uv cache path
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
cache-local-path: "/path/to/cache"
```
@@ -191,7 +191,7 @@ If you want to prune the cache before saving it, enable cache pruning with the `
```yaml
- name: Prune the cache before saving it
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
prune-cache: true
@@ -210,7 +210,7 @@ To force managed Python installs, set `UV_PYTHON_PREFERENCE=only-managed`.
```yaml
- name: Cache Python installs
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-python: true
@@ -228,7 +228,7 @@ If you want to ignore this, set the `ignore-nothing-to-cache` input to `true`.
```yaml
- name: Ignore nothing to cache
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
ignore-nothing-to-cache: true
+7 -5
View File
@@ -11,7 +11,7 @@ You can specify a checksum to override those values. The sha256 hashes can also
```yaml
- name: Install a specific version and validate the checksum
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "0.3.1"
checksum: "e11b01402ab645392c7ad6044db63d37e4fd1e745e015306993b07695ea5f9f8"
@@ -20,10 +20,12 @@ You can specify a checksum to override those values. The sha256 hashes can also
## Manifest file
By default, setup-uv reads version metadata from
[`astral-sh/versions`](https://github.com/astral-sh/versions).
the [Astral mirror](https://releases.astral.sh/github/versions/main/v1/uv.ndjson).
If the mirror request fails, it falls back to [`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
custom uv builds or alternate download locations.
custom uv builds or alternate download locations. Custom manifest URLs do not fall back to the
default sources.
### Format
@@ -40,7 +42,7 @@ The `archive_format` field is currently ignored.
```yaml
- name: Use a custom manifest file
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
manifest-file: "https://example.com/my-custom-manifest.ndjson"
```
@@ -59,7 +61,7 @@ You can disable this by setting the `add-problem-matchers` input to `false`.
```yaml
- name: Install the latest version of uv without problem matchers
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
add-problem-matchers: false
```
+14 -13
View File
@@ -9,7 +9,7 @@ This allows directly using it in later steps:
```yaml
- name: Install the latest version of uv and activate the environment
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
activate-environment: true
- run: uv pip install pip
@@ -32,7 +32,7 @@ key: build-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup-uv.outputs.python
You can customize the venv location with `venv-path`, for example to place it in the runner temp directory:
```yaml
- uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
activate-environment: true
venv-path: ${{ runner.temp }}/custom-venv
@@ -50,12 +50,13 @@ You can customize the venv location with `venv-path`, for example to place it in
## GitHub authentication token
By default, this action resolves available uv versions from
[`astral-sh/versions`](https://github.com/astral-sh/versions), then downloads uv artifacts from
GitHub Releases.
By default, this action fetches version metadata and uv archives from the Astral mirror.
If a manifest request fails, it falls back to `raw.githubusercontent.com`. If an archive download
fails, it falls back to GitHub Releases.
You can provide a token via `github-token` to authenticate those downloads. By default, the
`GITHUB_TOKEN` secret is used, which is automatically provided by GitHub Actions.
You can provide a token via `github-token` to authenticate GitHub Releases downloads. The token
is not sent to the Astral mirror or used for manifest requests. By default, the `GITHUB_TOKEN`
secret is used, which is automatically provided by GitHub Actions.
If the default
[permissions for the GitHub token](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)
@@ -63,7 +64,7 @@ are not sufficient, you can provide a custom GitHub token with the necessary per
```yaml
- name: Install the latest version of uv with a custom GitHub token
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
```
@@ -81,7 +82,7 @@ input:
```yaml
- name: Install the latest version of uv with a custom tool dir
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
tool-dir: "/path/to/tool/dir"
```
@@ -100,7 +101,7 @@ If you want to change this behaviour (especially on self-hosted runners) you can
```yaml
- name: Install the latest version of uv with a custom tool bin dir
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
tool-bin-dir: "/path/to/tool-bin/dir"
```
@@ -117,7 +118,7 @@ This action supports expanding the `~` character to the user's home directory fo
```yaml
- name: Expand the tilde character
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
cache-local-path: "~/path/to/cache"
tool-dir: "~/path/to/tool/dir"
@@ -134,7 +135,7 @@ If you want to ignore this, set the `ignore-empty-workdir` input to `true`.
```yaml
- name: Ignore empty workdir
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
ignore-empty-workdir: true
```
@@ -160,7 +161,7 @@ This action sets several environment variables that influence uv's behavior and
```yaml
- name: Example using environment variables
uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
python-version: "3.12"
tool-dir: "/custom/tool/dir"
+18
View File
@@ -1,4 +1,22 @@
{
"aarch64-apple-darwin-0.13.6": "60fbd5c8a1ed681845eea28d9d622fcde03c51e91a43465b64a1e17db1ed3472",
"aarch64-pc-windows-msvc-0.13.6": "c2426c0c8e28b53d8c440e47a18d96ad4db51e159866c0e81435b196d7f0081c",
"aarch64-unknown-linux-gnu-0.13.6": "229e194255c7958d86d56e8790d969a6f74736592133f0dfd0076f754c642c1d",
"aarch64-unknown-linux-musl-0.13.6": "819692e404d23e5aae6bc44c0e260f1f5492fd1910ab4693b2c650f926dbe800",
"arm-unknown-linux-musleabihf-0.13.6": "57ac0f7c04deb42c5d686b4eeeef555c442db6ffea16fe4cbd7adb0384403794",
"armv7-unknown-linux-gnueabihf-0.13.6": "d00cd4949c4524c934afcfee1aedfa9d337cf4e43be4d6b692ad8d74d0a65562",
"armv7-unknown-linux-musleabihf-0.13.6": "b215398c886e8cc2cfa282fe346c02025957f8633b75a3d4fd848e0adda4eddd",
"i686-pc-windows-msvc-0.13.6": "32ceb64db231cbedfd499f7654c72e4c0b564f2846f9e76c0a4a7b2d03d7e67c",
"i686-unknown-linux-gnu-0.13.6": "665ea831c38d342900950e606beb2ccc37b7ba0fcefc37b814eb4b076305f2b6",
"i686-unknown-linux-musl-0.13.6": "de3a015c4b0fce63c178ae4fa95c94c873adfd92fa1e258c6a2a94e529812629",
"powerpc64le-unknown-linux-gnu-0.13.6": "3b2847185ec2946fcc928500efef7e3e74c255d3be6f2cb435081a84885d8c6c",
"riscv64gc-unknown-linux-gnu-0.13.6": "517052603ed46483b59d8875c9c61a577946b8f493c73e4339e45e7b119171d0",
"riscv64gc-unknown-linux-musl-0.13.6": "659a95dc6aee3ecf86742a08d8ca6c6261422121cbd41decc0042f5a71af6305",
"s390x-unknown-linux-gnu-0.13.6": "fb56d731308aa5c7718059d71afcb14d9a933a974997cee3d4eb5d06fc462a4b",
"x86_64-apple-darwin-0.13.6": "63ba17fdda55ad1a230d4b37fc6017ffa10c23688c83818bd3bfdf914c652a02",
"x86_64-pc-windows-msvc-0.13.6": "a2a8820d5eea32f08ef467ef3b7f66883a9b076d5737a2fc2fbb5f458d1bb50f",
"x86_64-unknown-linux-gnu-0.13.6": "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645",
"x86_64-unknown-linux-musl-0.13.6": "5d61f26b6c7213779eda90edc6971ea6b0b796bfb8d49a574c8ad69b59838548",
"aarch64-apple-darwin-0.13.5": "743f85035a1996ecb350659e01cd9faea9709829be09b1b4b03c73eaf3c9cd73",
"aarch64-pc-windows-msvc-0.13.5": "09f47edf90726084a70f9426f6e3ca4f46e9bf7cbf23b1716ec64d60b055fae3",
"aarch64-unknown-linux-gnu-0.13.5": "4bb69cf95ed13f23713bb7bc09f241896ea0c75b7c557e615a20604b82f9c403",
+18 -1
View File
@@ -1,7 +1,10 @@
import { createInterface } from "node:readline";
import { Readable } from "node:stream";
import * as core from "@actions/core";
import { VERSIONS_MANIFEST_URL } from "../utils/constants";
import {
GITHUB_VERSIONS_MANIFEST_URL,
VERSIONS_MANIFEST_URL,
} from "../utils/constants";
import { fetch } from "../utils/fetch";
import * as log from "../utils/logging";
import { selectDefaultVariant } from "./variant-selection";
@@ -167,6 +170,20 @@ export function clearManifestCache(manifestUrl?: string): void {
}
async function fetchManifestResponse(manifestUrl: string) {
try {
return await fetchManifestResponseFromUrl(manifestUrl);
} catch (error) {
if (manifestUrl !== VERSIONS_MANIFEST_URL) {
throw error;
}
log.info(
`Failed to fetch manifest from Astral mirror, falling back to GitHub: ${(error as Error).message}`,
);
return await fetchManifestResponseFromUrl(GITHUB_VERSIONS_MANIFEST_URL);
}
}
async function fetchManifestResponseFromUrl(manifestUrl: string) {
let response: Awaited<ReturnType<typeof fetch>> | undefined;
for (let attempt = 1; attempt <= MANIFEST_FETCH_ATTEMPTS; attempt++) {
log.info(`Fetching manifest data from ${manifestUrl} ...`);
+4 -2
View File
@@ -159,8 +159,10 @@ async function saveCacheToKey(
}
log.info(`Including ${cacheName} path: ${cachePath}`);
await cache.saveCache([cachePath], cacheKey);
log.info(`${cacheName} saved with key: ${cacheKey}`);
const cacheId = await cache.saveCache([cachePath], cacheKey);
if (cacheId !== -1) {
log.info(`${cacheName} saved with key: ${cacheKey}`);
}
}
run();
+2
View File
@@ -2,6 +2,8 @@ export const TOOL_CACHE_NAME = "uv";
export const STATE_UV_PATH = "uv-path";
export const STATE_UV_VERSION = "uv-version";
export const VERSIONS_MANIFEST_URL =
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
export const GITHUB_VERSIONS_MANIFEST_URL =
"https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
/** GitHub Releases URL prefix for uv artifacts. */
+3 -1
View File
@@ -69,5 +69,7 @@ function getUvVersionFromAllDependencies(
function getUvVersionFromDependency(dependency: string): string | undefined {
const dependencyWithoutMarker = dependency.split(";", 1)[0]?.trim();
return dependencyWithoutMarker?.match(/^uv([=<>~!]+\S*)/)?.[1].trim();
return dependencyWithoutMarker
?.match(/^uv\s*((?:[=<>~!]+\s*[^\s,]+\s*,?\s*)+)/)?.[1]
.replace(/\s/g, "");
}
+18 -3
View File
@@ -169,7 +169,9 @@ async function findHighestSatisfyingVersion(
): Promise<string | undefined> {
// This fast path assumes uv releases are semver-monotonic: newer manifest
// entries always have higher versions, with no lower-version backports.
const semverRange = semver.validRange(versionSpecifier);
const semverRange = isCompatibleReleaseSpecifier(versionSpecifier)
? null
: semver.validRange(versionSpecifier);
if (semverRange !== null) {
const semverMatch = await getFirstMatchingVersion((version) =>
semver.satisfies(version, semverRange),
@@ -193,11 +195,22 @@ async function findHighestSatisfyingVersion(
return pep440Match;
}
/**
* `~=` is the PEP 440 compatible release operator. semver accepts it as a
* tilde range with a narrower upper bound (`~=0.5` as `<0.6.0` instead of
* `<1.0`), so it must only be evaluated as PEP 440.
*/
function isCompatibleReleaseSpecifier(versionSpecifier: string): boolean {
return versionSpecifier.includes("~=");
}
function maxSatisfying(
versions: string[],
version: string,
): string | undefined {
const maxSemver = tc.evaluateVersions(versions, version);
const maxSemver = isCompatibleReleaseSpecifier(version)
? ""
: tc.evaluateVersions(versions, version);
if (maxSemver !== "") {
core.debug(`Found a version that satisfies the semver range: ${maxSemver}`);
return maxSemver;
@@ -218,7 +231,9 @@ function minSatisfying(
versions: string[],
version: string,
): string | undefined {
const minSemver = semver.minSatisfying(versions, version);
const minSemver = isCompatibleReleaseSpecifier(version)
? null
: semver.minSatisfying(versions, version);
if (minSemver !== null) {
core.debug(`Found a version that satisfies the semver range: ${minSemver}`);
return minSemver;