mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-02-18 06:51:45 +00:00
feat: new option server-url to support custom github url
Signed-off-by: Zoupers <qy@zouper.cn>
This commit is contained in:
parent
de3494511c
commit
3b53614f9b
4 changed files with 12 additions and 11 deletions
|
|
@ -18,6 +18,10 @@ inputs:
|
|||
checksum:
|
||||
description: "The checksum of the uv version to install"
|
||||
required: false
|
||||
server-url:
|
||||
description: "The server url to use when downloading uv"
|
||||
required: false
|
||||
default: "https://github.com"
|
||||
github-token:
|
||||
description:
|
||||
"Used to increase the rate limit when retrieving versions and downloading uv."
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export function tryGetFromToolCache(
|
|||
}
|
||||
|
||||
export async function downloadVersion(
|
||||
githubUrl: string,
|
||||
serverUrl: string,
|
||||
platform: Platform,
|
||||
arch: Architecture,
|
||||
version: string,
|
||||
|
|
@ -37,7 +37,7 @@ export async function downloadVersion(
|
|||
if (platform === "pc-windows-msvc") {
|
||||
extension = ".zip";
|
||||
}
|
||||
const downloadUrl = `${githubUrl}/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
|
||||
const downloadUrl = `${serverUrl}/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
|
||||
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||
|
||||
const downloadPath = await tc.downloadTool(
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {
|
|||
toolDir,
|
||||
version as versionInput,
|
||||
workingDirectory,
|
||||
githubUrl,
|
||||
serverUrl,
|
||||
} from "./utils/inputs";
|
||||
import * as exec from "@actions/exec";
|
||||
import fs from "node:fs";
|
||||
|
|
@ -96,7 +96,7 @@ async function setupUv(
|
|||
}
|
||||
|
||||
const downloadVersionResult = await downloadVersion(
|
||||
githubUrl,
|
||||
serverUrl,
|
||||
platform,
|
||||
arch,
|
||||
resolvedVersion,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export const ignoreEmptyWorkdir =
|
|||
core.getInput("ignore-empty-workdir") === "true";
|
||||
export const toolBinDir = getToolBinDir();
|
||||
export const toolDir = getToolDir();
|
||||
export const githubUrl = getGithubUrl();
|
||||
export const serverUrl = getServerUrl();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
|
||||
function getEnableCache(): boolean {
|
||||
|
|
@ -86,13 +86,10 @@ function expandTilde(input: string): string {
|
|||
return input;
|
||||
}
|
||||
|
||||
function getGithubUrl(): string {
|
||||
let url = "https://github.com";
|
||||
if(process.env.GITHUB_URL) {
|
||||
url = process.env.GITHUB_URL;
|
||||
}
|
||||
function getServerUrl(): string {
|
||||
const url = core.getInput("server-url");
|
||||
if(url.endsWith("/")) {
|
||||
url = url.replaceAll(/\/+$/g, "")
|
||||
return url.replaceAll(/\/+$/g, "")
|
||||
}
|
||||
return url;
|
||||
}
|
||||
Loading…
Reference in a new issue