From 44abb8da3ea1fbb8f870a990cfe30c32cb3dbcfc Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:03:33 +0200 Subject: [PATCH 01/10] feat: allow specifying binary name --- .github/workflows/test.yml | 16 ++++++++++++++++ action.yml | 5 +++++ main.js | 5 ++++- src/install.js | 12 ++++++++++-- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8fd2e65..343239e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/action.yml b/action.yml index 74d15ef..b0d67b2 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/main.js b/main.js index 33574a0..4c50cb2 100644 --- a/main.js +++ b/main.js @@ -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) { diff --git a/src/install.js b/src/install.js index fdc8cce..9e05976 100644 --- a/src/install.js +++ b/src/install.js @@ -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, @@ -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}.`); From c5def1e498501e667614b37ba082f63b9a103d6e Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:39:11 +0200 Subject: [PATCH 02/10] ci? From e1810ff36f4259e9eacb74ab7f8aa6006fad518c Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:41:12 +0200 Subject: [PATCH 03/10] fix --- .github/workflows/test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 343239e..dd1a5f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,16 +64,13 @@ jobs: 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 }} + deno-binary-name: deno_foo - - name: Check version + - name: Check binary exists run: deno_foo -V From 5ae88918d3d3beb2cce7b52dd74e77e0fb0b31e5 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:42:45 +0200 Subject: [PATCH 04/10] dbg --- src/install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.js b/src/install.js index 9e05976..a688cc7 100644 --- a/src/install.js +++ b/src/install.js @@ -30,7 +30,7 @@ async function install(version, binaryName) { const zipPath = await tc.downloadTool(url); const extractedFolder = await tc.extractZip(zipPath); - core.info(extractedFolder); + (await fs.readdir(extractedFolder)).map(e => core.info(e)); if (binaryName !== "deno") { //await fs.rename(extractedFolder, extractedFolder); From fa015402a4ea535ddbf2b8dc913b6c570383f5fb Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:43:41 +0200 Subject: [PATCH 05/10] fix --- src/install.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/install.js b/src/install.js index a688cc7..2a6c22f 100644 --- a/src/install.js +++ b/src/install.js @@ -30,10 +30,8 @@ async function install(version, binaryName) { const zipPath = await tc.downloadTool(url); const extractedFolder = await tc.extractZip(zipPath); - (await fs.readdir(extractedFolder)).map(e => core.info(e)); - if (binaryName !== "deno") { - //await fs.rename(extractedFolder, extractedFolder); + await fs.rename(path.join(extractedFolder, "deno"), path.join(extractedFolder, binaryName)); } const newCachedPath = await tc.cacheDir( From 108355283dd06742bcdf630e28cc1015338b7d48 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:43:58 +0200 Subject: [PATCH 06/10] fmt --- src/install.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/install.js b/src/install.js index 2a6c22f..ed6c5dd 100644 --- a/src/install.js +++ b/src/install.js @@ -31,7 +31,10 @@ async function install(version, binaryName) { const extractedFolder = await tc.extractZip(zipPath); if (binaryName !== "deno") { - await fs.rename(path.join(extractedFolder, "deno"), path.join(extractedFolder, binaryName)); + await fs.rename( + path.join(extractedFolder, "deno"), + path.join(extractedFolder, binaryName), + ); } const newCachedPath = await tc.cacheDir( From 1d8991ee3703d59a80ffb466d695ac42ba67b802 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 11 Sep 2024 21:46:09 +0200 Subject: [PATCH 07/10] clean up --- action.yml | 2 -- main.js | 5 +---- src/install.js | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index b0d67b2..59ce8fb 100644 --- a/action.yml +++ b/action.yml @@ -18,8 +18,6 @@ outputs: 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" diff --git a/main.js b/main.js index 4c50cb2..33574a0 100644 --- a/main.js +++ b/main.js @@ -41,13 +41,10 @@ async function main() { } version ${version.version}.`, ); - const binaryName = core.getInput("deno-binary-name"); - - await install(version, binaryName); + await install(version); core.setOutput("deno-version", version.version); core.setOutput("is-canary", version.isCanary); - core.setOutput("deno-binary-name", binaryName); core.info("Installation complete."); } catch (err) { diff --git a/src/install.js b/src/install.js index ed6c5dd..8d43226 100644 --- a/src/install.js +++ b/src/install.js @@ -7,9 +7,8 @@ const tc = require("@actions/tool-cache"); /** * @param {import("./version").Version} version - * @param {string} binaryName */ -async function install(version, binaryName) { +async function install(version) { const cachedPath = tc.find( "deno", version.isCanary ? `0.0.0-${version.version}` : version.version, @@ -30,6 +29,7 @@ async function install(version, binaryName) { const zipPath = await tc.downloadTool(url); const extractedFolder = await tc.extractZip(zipPath); + const binaryName = core.getInput("deno-binary-name"); if (binaryName !== "deno") { await fs.rename( path.join(extractedFolder, "deno"), From 28cada01245d5173360d8a70ed4a37b6ba577ad8 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Thu, 12 Sep 2024 12:21:56 +0200 Subject: [PATCH 08/10] windows --- .github/workflows/test.yml | 4 +++- src/install.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd1a5f7..a7e92cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,9 @@ jobs: run: deno -V | grep -q "deno 1\.43\.1" test-binary-name: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - uses: actions/checkout@v3 diff --git a/src/install.js b/src/install.js index 8d43226..abae86f 100644 --- a/src/install.js +++ b/src/install.js @@ -32,8 +32,14 @@ async function install(version) { const binaryName = core.getInput("deno-binary-name"); if (binaryName !== "deno") { await fs.rename( - path.join(extractedFolder, "deno"), - path.join(extractedFolder, binaryName), + path.join( + extractedFolder, + process.platform === "win32" ? "deno.exe" : "deno", + ), + path.join( + extractedFolder, + process.platform === "win32" ? binaryName + ".exe" : binaryName, + ), ); } From 5b672583d62d3c92a509c505ddef2db1f878d2e5 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Thu, 12 Sep 2024 12:37:31 +0200 Subject: [PATCH 09/10] fix --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7e92cd..b9d4769 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,8 +64,9 @@ jobs: test-binary-name: runs-on: ${{ matrix.os }} - matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - uses: actions/checkout@v3 From ea177fd0303fc04fd67c6f7f6fb40cee06f2e937 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Thu, 12 Sep 2024 12:44:50 +0200 Subject: [PATCH 10/10] add readme example --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 08c8cb5..af64791 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,11 @@ The extension can also automatically read the file from with: deno-version-file: .dvmrc ``` + +### Specifying binary name + +```yaml +- uses: denoland/setup-deno@v1 + with: + deno-binary-name: deno_latest +```