Skip to content

Commit

Permalink
Add support for custom download URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mamercad committed Feb 24, 2025
1 parent 19e5e84 commit 56cf771
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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. |


<div align="center">
<a target="_blank" href="https://astral.sh" style="background:none">
<img src="https://raw.githubusercontent.com/astral-sh/uv/main/assets/svg/Astral.svg" alt="Made by Astral">
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
3 changes: 2 additions & 1 deletion src/download/download-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/utils/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

0 comments on commit 56cf771

Please sign in to comment.