Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,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
```
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions dist/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -20276,8 +20276,9 @@ async function install(version) {
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);
Expand Down Expand Up @@ -20328,7 +20329,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);
Expand Down
13 changes: 9 additions & 4 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -39,16 +39,21 @@ export async function install(version: Version) {
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,
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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::${
Expand Down
Loading