Add input manifest-file (#454)

Adds capability to maintain custom uv builds or to override the default
sources
This commit is contained in:
Kevin Stillhammer
2025-06-18 22:33:20 +02:00
committed by GitHub
parent 7bbb36f434
commit 60cc2b4585
14 changed files with 493 additions and 126 deletions

21
src/utils/fetch.ts Normal file
View File

@ -0,0 +1,21 @@
import { fetch as undiciFetch, ProxyAgent, type RequestInit } from "undici";
export function getProxyAgent() {
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
if (httpProxy) {
return new ProxyAgent(httpProxy);
}
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
if (httpsProxy) {
return new ProxyAgent(httpsProxy);
}
return undefined;
}
export const fetch = async (url: string, opts: RequestInit) =>
await undiciFetch(url, {
dispatcher: getProxyAgent(),
...opts,
});

View File

@ -1,5 +1,6 @@
import * as core from "@actions/core";
import path from "node:path";
import { getManifestFromRepo } from "@actions/tool-cache";
export const version = core.getInput("version");
export const pythonVersion = core.getInput("python-version");
@ -19,6 +20,7 @@ export const toolBinDir = getToolBinDir();
export const toolDir = getToolDir();
export const serverUrl = core.getInput("server-url");
export const githubToken = core.getInput("github-token");
export const manifestFile = getManifestFile();
function getEnableCache(): boolean {
const enableCacheInput = core.getInput("enable-cache");
@ -85,3 +87,11 @@ function expandTilde(input: string): string {
}
return input;
}
function getManifestFile(): string | undefined {
const manifestFileInput = core.getInput("manifest-file");
if (manifestFileInput !== "") {
return manifestFileInput;
}
return undefined;
}

View File

@ -8,7 +8,7 @@ import {
type PaginateInterface,
} from "@octokit/plugin-paginate-rest";
import { legacyRestEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
import { fetch as undiciFetch, ProxyAgent, type RequestInit } from "undici";
import { fetch as customFetch } from "./fetch";
export type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";
@ -17,26 +17,6 @@ const DEFAULTS = {
userAgent: "setup-uv",
};
export function getProxyAgent() {
const httpProxy = process.env.HTTP_PROXY || process.env.http_prox;
if (httpProxy) {
return new ProxyAgent(httpProxy);
}
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
if (httpsProxy) {
return new ProxyAgent(httpsProxy);
}
return undefined;
}
export const customFetch = async (url: string, opts: RequestInit) =>
await undiciFetch(url, {
dispatcher: getProxyAgent(),
...opts,
});
export const Octokit: typeof Core &
Constructor<
{