From 56cf771d34b20bcc70724ba4fdb3f656548301df Mon Sep 17 00:00:00 2001 From: Mark Mercado Date: Mon, 24 Feb 2025 12:01:04 -0500 Subject: [PATCH] Add support for custom download URL --- README.md | 20 ++++++++++---------- action.yml | 4 ++++ src/download/download-version.ts | 3 ++- src/utils/inputs.ts | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f437a14..766b808 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,15 @@ fix). ## Usage -| Input | Description | Default | -|----------------|--------------------------------------------------------------------------------------------------------------------------------------------|--------------------| -| `version` | The version of Ruff to install. See [Install specific versions](#install-specific-versions) | `latest` | -| `version-file` | The file to read the version from. See [Install a version from a specified version file](#install-a-version-from-a-specified-version-file) | None | -| `args` | The arguments to pass to the `ruff` command. See [Configuring Ruff] | `check` | -| `src` | The directory or single files to run `ruff` on. | [github.workspace] | -| `checksum` | The sha256 checksum of the downloaded executable. | None | -| `github-token` | The GitHub token to use for authentication. | `GITHUB_TOKEN` | +| Input | Description | Default | +| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | +| `version` | The version of Ruff to install. See [Install specific versions](#install-specific-versions) | `latest` | +| `version-file` | The file to read the version from. See [Install a version from a specified version file](#install-a-version-from-a-specified-version-file) | None | +| `args` | The arguments to pass to the `ruff` command. See [Configuring Ruff] | `check` | +| `src` | The directory or single files to run `ruff` on. | [github.workspace] | +| `checksum` | The sha256 checksum of the downloaded executable. | None | +| `github-token` | The GitHub token to use for authentication. | `GITHUB_TOKEN` | +| `custom-download-url` | Custom download URL for ruff. | https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}${extension} | ### Basic @@ -167,10 +168,9 @@ are not sufficient, you can provide a custom GitHub token with the necessary per ## Outputs | Output | Description | -|----------------|-----------------------------------------| +| -------------- | --------------------------------------- | | `ruff-version` | The version of Ruff that was installed. | -
Made by Astral diff --git a/action.yml b/action.yml index 72ca55e..98ed0a4 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,10 @@ inputs: ruff." required: false default: ${{ github.token }} + custom-download-url: + description: "Custom URL to download the ruff version from" + required: false + default: "https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}${extension}" outputs: ruff-version: description: "The installed ruff version. Useful when using latest." diff --git a/src/download/download-version.ts b/src/download/download-version.ts index ad7cda9..076c27f 100644 --- a/src/download/download-version.ts +++ b/src/download/download-version.ts @@ -32,13 +32,14 @@ export async function downloadVersion( version: string, checkSum: string | undefined, githubToken: string, + customDownloadUrl?: string, ): Promise<{ version: string; cachedToolDir: string }> { const artifact = `ruff-${arch}-${platform}`; let extension = ".tar.gz"; if (platform === "pc-windows-msvc") { extension = ".zip"; } - const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}${extension}`; + const downloadUrl = customDownloadUrl || `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}${extension}`; core.info(`Downloading ruff from "${downloadUrl}" ...`); const downloadPath = await tc.downloadTool( diff --git a/src/utils/inputs.ts b/src/utils/inputs.ts index 6b59b93..64fd40e 100644 --- a/src/utils/inputs.ts +++ b/src/utils/inputs.ts @@ -6,3 +6,4 @@ export const githubToken = core.getInput("github-token"); export const args = core.getInput("args"); export const src = core.getInput("src"); export const versionFile = core.getInput("version-file"); +export const customDownloadUrl = core.getInput("custom-download-url");