Skip to content

Commit

Permalink
feat: allow specifying binary name
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Sep 11, 2024
1 parent fa660b3 commit 44abb8d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,19 @@ jobs:

- name: Check version
run: deno -V | grep -q "deno 1\.43\.1"

test-binary-name:
runs-on: ubuntu-latest
strategy:
matrix:
deno-binary-name: deno_foo
steps:
- uses: actions/checkout@v3

- name: Setup Deno
uses: ./
with:
deno-version-file: ${{ matrix.deno-version-file }}

- name: Check version
run: deno_foo -V
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ inputs:
default: "1.x"
deno-version-file:
description: File containing the Deno version to install such as .dvmrc or .tool-versions.
deno-binary-name:
description: The name to use for the binary.
default: "deno"
outputs:
deno-version:
description: "The Deno version that was installed."
is-canary:
description: "If the installed Deno version was a canary version."
deno-binary-name:
description: The name to use for the binary.
runs:
using: "node20"
main: "main.js"
5 changes: 4 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ async function main() {
} version ${version.version}.`,
);

await install(version);
const binaryName = core.getInput("deno-binary-name");

await install(version, binaryName);

core.setOutput("deno-version", version.version);
core.setOutput("is-canary", version.isCanary);
core.setOutput("deno-binary-name", binaryName);

core.info("Installation complete.");
} catch (err) {
Expand Down
12 changes: 10 additions & 2 deletions src/install.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const os = require("os");
const path = require("path");
const fs = require("fs/promises");
const process = require("process");
const core = require("@actions/core");
const tc = require("@actions/tool-cache");

/**
* @param {import("./version").Version} version
* @param {string} binaryName
*/
async function install(version) {
async function install(version, binaryName) {
const cachedPath = tc.find(
"deno",
version.isCanary ? `0.0.0-${version.version}` : version.version,
Expand All @@ -28,9 +30,15 @@ async function install(version) {
const zipPath = await tc.downloadTool(url);
const extractedFolder = await tc.extractZip(zipPath);

core.info(extractedFolder);

if (binaryName !== "deno") {
//await fs.rename(extractedFolder, extractedFolder);
}

const newCachedPath = await tc.cacheDir(
extractedFolder,
"deno",
binaryName,
version.isCanary ? `0.0.0-${version.version}` : version.version,
);
core.info(`Cached Deno to ${newCachedPath}.`);
Expand Down

0 comments on commit 44abb8d

Please sign in to comment.