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: checksum:
description: "The checksum of the uv version to install" description: "The checksum of the uv version to install"
required: false required: false
server-url:
description: "The server url to use when downloading uv"
required: false
default: "https://github.com"
github-token: github-token:
description: description:
"Used to increase the rate limit when retrieving versions and downloading uv." "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( export async function downloadVersion(
githubUrl: string, serverUrl: string,
platform: Platform, platform: Platform,
arch: Architecture, arch: Architecture,
version: string, version: string,
@ -37,7 +37,7 @@ export async function downloadVersion(
if (platform === "pc-windows-msvc") { if (platform === "pc-windows-msvc") {
extension = ".zip"; 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}" ...`); core.info(`Downloading uv from "${downloadUrl}" ...`);
const downloadPath = await tc.downloadTool( const downloadPath = await tc.downloadTool(

View file

@ -25,7 +25,7 @@ import {
toolDir, toolDir,
version as versionInput, version as versionInput,
workingDirectory, workingDirectory,
githubUrl, serverUrl,
} from "./utils/inputs"; } from "./utils/inputs";
import * as exec from "@actions/exec"; import * as exec from "@actions/exec";
import fs from "node:fs"; import fs from "node:fs";
@ -96,7 +96,7 @@ async function setupUv(
} }
const downloadVersionResult = await downloadVersion( const downloadVersionResult = await downloadVersion(
githubUrl, serverUrl,
platform, platform,
arch, arch,
resolvedVersion, resolvedVersion,

View file

@ -17,7 +17,7 @@ export const ignoreEmptyWorkdir =
core.getInput("ignore-empty-workdir") === "true"; core.getInput("ignore-empty-workdir") === "true";
export const toolBinDir = getToolBinDir(); export const toolBinDir = getToolBinDir();
export const toolDir = getToolDir(); export const toolDir = getToolDir();
export const githubUrl = getGithubUrl(); export const serverUrl = getServerUrl();
export const githubToken = core.getInput("github-token"); export const githubToken = core.getInput("github-token");
function getEnableCache(): boolean { function getEnableCache(): boolean {
@ -86,13 +86,10 @@ function expandTilde(input: string): string {
return input; return input;
} }
function getGithubUrl(): string { function getServerUrl(): string {
let url = "https://github.com"; const url = core.getInput("server-url");
if(process.env.GITHUB_URL) {
url = process.env.GITHUB_URL;
}
if(url.endsWith("/")) { if(url.endsWith("/")) {
url = url.replaceAll(/\/+$/g, "") return url.replaceAll(/\/+$/g, "")
} }
return url; return url;
} }