feat: new option server-url to support custom github url

Signed-off-by: Zoupers <qy@zouper.cn>
This commit is contained in:
Zoupers 2025-05-20 08:35:05 +08:00
parent de3494511c
commit 3b53614f9b
No known key found for this signature in database
GPG key ID: 6F77683A1BC51B5C
4 changed files with 12 additions and 11 deletions

View file

@ -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."

View file

@ -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(

View file

@ -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,

View file

@ -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;
}