From e1920e4cc71da0768a2fb78150af78bc884d5863 Mon Sep 17 00:00:00 2001 From: ryu <114303361+ryuapp@users.noreply.github.com> Date: Sat, 15 Nov 2025 01:57:25 +0900 Subject: [PATCH 1/3] feat: add target option --- .github/workflows/test.yml | 13 +++++++++++++ README.md | 10 ++++++++++ action.yml | 2 ++ dist/main.mjs | 7 ++++--- src/install.ts | 4 ++-- src/main.ts | 3 ++- 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3162b4..30bf507 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -80,6 +80,19 @@ jobs: - name: Check binary exists run: deno_foo -V + test-target: + runs-on: windows-11-arm + steps: + - uses: actions/checkout@v5 + + - name: Setup Deno with target x64 + uses: ./ + with: + target: x86_64-pc-windows-msvc + + - name: Check version + run: deno --version + test-setup-cache: runs-on: ${{ matrix.os }} strategy: diff --git a/README.md b/README.md index 4f276b8..d762dd9 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,16 @@ number. - run: echo "Deno version is ${{ steps.deno.outputs.deno-version }}" ``` +### Determining the target platform + +You can determine the target platform of Deno. + +```yaml +- uses: denoland/setup-deno@v2 + with: + target: x86_64-pc-windows-msvc +``` + ### Caching dependencies downloaded by Deno automatically Dependencies installed by Deno can be cached automatically between workflow diff --git a/action.yml b/action.yml index 9f4d68f..3595e05 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,8 @@ inputs: deno-binary-name: description: The name to use for the binary. default: "deno" + target: + description: The target platform of the binary (e.g., "x86_64-pc-windows-msvc"). cache: description: Cache downloaded modules & packages automatically in GitHub Actions cache. default: "false" diff --git a/dist/main.mjs b/dist/main.mjs index d4dc23d..32dbabf 100644 --- a/dist/main.mjs +++ b/dist/main.mjs @@ -20252,14 +20252,14 @@ var import_tool_cache = __toESM(require_tool_cache(), 1); //#endregion //#region src/install.ts -async function install(version) { +async function install(version, target = "") { const cachedPath = import_tool_cache.find("deno", version.kind === "canary" ? `0.0.0-${version.version}` : version.version); if (cachedPath) { import_core.info(`Using cached Deno installation from ${cachedPath}.`); import_core.addPath(cachedPath); return; } - const zip = zipName(); + const zip = target ? `deno-${target}.zip` : zipName(); let url; switch (version.kind) { case "canary": @@ -20328,7 +20328,8 @@ async function main() { const version = await resolveVersion(range); if (version === null) exit("Could not resolve a version for the given range."); import_core.info(`Going to install ${version.kind} version ${version.version}.`); - await install(version); + const target = import_core.getInput("target"); + await install(version, target); import_core.info(`::add-matcher::${path.join(import.meta.dirname ?? ".", "..", "deno-problem-matchers.json")}`); import_core.setOutput("deno-version", version.version); import_core.setOutput("release-channel", version.kind); diff --git a/src/install.ts b/src/install.ts index aacdf29..6077ca9 100644 --- a/src/install.ts +++ b/src/install.ts @@ -6,7 +6,7 @@ import core from "@actions/core"; import tc from "@actions/tool-cache"; import type { Version } from "./version.ts"; -export async function install(version: Version) { +export async function install(version: Version, target: string = "") { const cachedPath = tc.find( "deno", version.kind === "canary" ? `0.0.0-${version.version}` : version.version, @@ -17,7 +17,7 @@ export async function install(version: Version) { return; } - const zip = zipName(); + const zip = target ? `deno-${target}.zip` : zipName(); let url; switch (version.kind) { diff --git a/src/main.ts b/src/main.ts index 39d1f08..da5bb31 100644 --- a/src/main.ts +++ b/src/main.ts @@ -45,7 +45,8 @@ async function main() { core.info(`Going to install ${version.kind} version ${version.version}.`); - await install(version); + const target = core.getInput("target"); + await install(version, target); core.info( `::add-matcher::${ From b557a7ee2da2f5b096d6b784060f063f525649fd Mon Sep 17 00:00:00 2001 From: ryu <114303361+ryuapp@users.noreply.github.com> Date: Mon, 17 Nov 2025 22:55:55 +0900 Subject: [PATCH 2/3] docs: explain what this is for --- README.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d762dd9..37ca228 100644 --- a/README.md +++ b/README.md @@ -142,16 +142,6 @@ number. - run: echo "Deno version is ${{ steps.deno.outputs.deno-version }}" ``` -### Determining the target platform - -You can determine the target platform of Deno. - -```yaml -- uses: denoland/setup-deno@v2 - with: - target: x86_64-pc-windows-msvc -``` - ### Caching dependencies downloaded by Deno automatically Dependencies installed by Deno can be cached automatically between workflow @@ -189,3 +179,17 @@ It is possible to customize the default hash # the default cache-hash of `${{ hashFiles('**/deno.lock') }}` cache-hash: ${{ hashFiles('**/deno.json') }} ``` + +### Determining the target platform + +You can determine the target platform of Deno. + +This can be used when automatic platform detection does not meet the conditions, +such as when you want to run x64 binaries on Windows Arm. + +```yaml +- uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + target: x86_64-pc-windows-msvc +``` From 221053e2a5952084e79b5c0d8005ba9852e54b53 Mon Sep 17 00:00:00 2001 From: ryu <114303361+ryuapp@users.noreply.github.com> Date: Mon, 17 Nov 2025 22:45:16 +0900 Subject: [PATCH 3/3] fix: preserve extension --- dist/main.mjs | 3 ++- src/install.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/main.mjs b/dist/main.mjs index 32dbabf..583ae36 100644 --- a/dist/main.mjs +++ b/dist/main.mjs @@ -20276,8 +20276,9 @@ async function install(version, target = "") { import_core.info(`Downloading Deno from ${url}.`); const zipPath = await import_tool_cache.downloadTool(url); const extractedFolder = await import_tool_cache.extractZip(zipPath); + const isWindowsPlatform = target ? target.includes("windows") : process$1.platform === "win32"; const binaryName = import_core.getInput("deno-binary-name"); - if (binaryName !== "deno") await fs.rename(path$1.join(extractedFolder, process$1.platform === "win32" ? "deno.exe" : "deno"), path$1.join(extractedFolder, process$1.platform === "win32" ? binaryName + ".exe" : binaryName)); + if (binaryName !== "deno") await fs.rename(path$1.join(extractedFolder, isWindowsPlatform ? "deno.exe" : "deno"), path$1.join(extractedFolder, isWindowsPlatform ? binaryName + ".exe" : binaryName)); const newCachedPath = await import_tool_cache.cacheDir(extractedFolder, binaryName, version.kind === "canary" ? `0.0.0-${version.version}` : version.version); import_core.info(`Cached Deno to ${newCachedPath}.`); import_core.addPath(newCachedPath); diff --git a/src/install.ts b/src/install.ts index 6077ca9..b799e2d 100644 --- a/src/install.ts +++ b/src/install.ts @@ -39,16 +39,21 @@ export async function install(version: Version, target: string = "") { const zipPath = await tc.downloadTool(url); const extractedFolder = await tc.extractZip(zipPath); + // Determine if the binary has .exe extension based on target or current platform + const isWindowsPlatform = target + ? target.includes("windows") + : process.platform === "win32"; + const binaryName = core.getInput("deno-binary-name"); if (binaryName !== "deno") { await fs.rename( path.join( extractedFolder, - process.platform === "win32" ? "deno.exe" : "deno", + isWindowsPlatform ? "deno.exe" : "deno", ), path.join( extractedFolder, - process.platform === "win32" ? binaryName + ".exe" : binaryName, + isWindowsPlatform ? binaryName + ".exe" : binaryName, ), ); }