Skip to content

Commit

Permalink
feat: Add artifact repo configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-lim-partior committed Aug 25, 2023
1 parent cb603ca commit bc06100
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
| --------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------ | -------- |
| `cache` | No | `true` | Whether to cache RPC responses or not. | bool |
| `version` | No | `nightly` | Version to install, e.g. `nightly` or `1.0.0`. **Note:** Foundry only has nightly builds for the time being. | string |
| `repository` | No | `https://github.com` | Artifact repository url prefix to download Foundry binaries from. It needs to be compliant with Github's path. | string |

### RPC Caching

Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ inputs:
This version number has to match a released version of Foundry.
The default value is `nightly`, which will pull the latest nightly build.
required: false
repository:
default: "https://github.com"
description: |
Artifact repository URL prefix.
Artifact repository from which to download the foundry artifact from.
The repo artifact path has to conform to the url format of github, like `${repository}/foundry-rs/foundry/releases/download/${version}/${fullFileName}`
The default value is `https://github.com`.
required: false

runs:
using: "node16"
Expand Down
8 changes: 5 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68384,9 +68384,11 @@ async function main() {
try {
// Get version input
const version = core.getInput("version");
// Get artifact repository input
const repository = core.getInput("repository");

// Download the archive containing the binaries
const download = getDownloadObject(version);
const download = getDownloadObject(repository, version);
core.info(`Downloading Foundry '${version}' from: ${download.url}`);
const pathToArchive = await toolCache.downloadTool(download.url);

Expand Down Expand Up @@ -68437,11 +68439,11 @@ function mapArch(arch) {
return mappings[arch] || arch;
}

function getDownloadObject(version) {
function getDownloadObject(repository, version) {
const platform = os.platform();
const filename = `foundry_${normalizeVersionName(version)}_${platform}_${mapArch(os.arch())}`;
const extension = platform === "win32" ? "zip" : "tar.gz";
const url = `https://github.com/foundry-rs/foundry/releases/download/${version}/${filename}.${extension}`;
const url = `${repository}/foundry-rs/foundry/releases/download/${version}/${filename}.${extension}`;

return {
url,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ async function main() {
try {
// Get version input
const version = core.getInput("version");
// Get artifact repository input
const repository = core.getInput("repository");

// Download the archive containing the binaries
const download = getDownloadObject(version);
const download = getDownloadObject(repository, version);
core.info(`Downloading Foundry '${version}' from: ${download.url}`);
const pathToArchive = await toolCache.downloadTool(download.url);

Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function mapArch(arch) {
return mappings[arch] || arch;
}

function getDownloadObject(version) {
function getDownloadObject(repository, version) {
const platform = os.platform();
const filename = `foundry_${normalizeVersionName(version)}_${platform}_${mapArch(os.arch())}`;
const extension = platform === "win32" ? "zip" : "tar.gz";
const url = `https://github.com/foundry-rs/foundry/releases/download/${version}/${filename}.${extension}`;
const url = `${repository}/foundry-rs/foundry/releases/download/${version}/${filename}.${extension}`;

return {
url,
Expand Down

0 comments on commit bc06100

Please sign in to comment.