Skip to content

Commit 60665d6

Browse files
authored
feat: add support for arm64 (#113)
also update dependencies
1 parent 49c7874 commit 60665d6

File tree

12 files changed

+66273
-100989
lines changed

12 files changed

+66273
-100989
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ inputs:
7171
True to cache downloads.
7272
default: true
7373
runs:
74-
using: 'node20'
74+
using: 'node24'
7575
main: 'dist/index.js'

dist/index.js

Lines changed: 59341 additions & 89428 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

Lines changed: 0 additions & 1786 deletions
This file was deleted.

dist/sourcemap-register.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

jest.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

package-lock.json

Lines changed: 6758 additions & 9682 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"format": "prettier --write '**/*.ts'",
1010
"format-check": "prettier --check '**/*.ts'",
1111
"lint": "eslint src/**/*.ts",
12-
"package": "ncc build --source-map --license licenses.txt",
12+
"package": "esbuild src/main.ts --bundle --platform=node --target=node24 --format=cjs --sourcemap --outfile=dist/index.js",
1313
"package-local": "export NODE_OPTIONS=--openssl-legacy-provider; ncc build --source-map --license licenses.txt",
14-
"test": "jest",
14+
"test": "vitest run",
1515
"all": "npm run build && npm run format && npm run lint && npm run package && npm test",
1616
"all-local": "npm run build && npm run format && npm run lint && npm run package-local && npm test"
1717
},
@@ -27,23 +27,22 @@
2727
"author": "",
2828
"license": "MIT",
2929
"dependencies": {
30-
"@actions/cache": "^4.0.3",
31-
"@actions/core": "^1.10.1",
32-
"@actions/tool-cache": "^2.0.2",
33-
"@types/normalize-path": "^3.0.2",
30+
"@actions/cache": "^6.0.0",
31+
"@actions/core": "^3.0.0",
32+
"@actions/tool-cache": "^4.0.0",
3433
"normalize-path": "^3.0.0"
3534
},
3635
"devDependencies": {
37-
"@types/node": "^22.15.17",
38-
"@typescript-eslint/parser": "^8.32.1",
39-
"@vercel/ncc": "^0.38.3",
36+
"@types/node": "^24.10.13",
37+
"@types/normalize-path": "^3.0.2",
38+
"@typescript-eslint/parser": "^8.56.0",
39+
"esbuild": "^0.27.3",
4040
"eslint": "^9.26.0",
4141
"eslint-plugin-github": "^6.0.0",
42-
"eslint-plugin-jest": "^28.11.0",
43-
"jest": "^29.7.0",
44-
"js-yaml": "^4.1.0",
45-
"prettier": "^2.8.8",
46-
"ts-jest": "^29.3.2",
47-
"typescript": "^5.8.3"
42+
"js-yaml": "^4.1.1",
43+
"prettier": "^3.8.1",
44+
"ts-jest": "^29.4.6",
45+
"typescript": "^5.9.3",
46+
"vitest": "^4.0.18"
4847
}
4948
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ async function run(platform: Platform): Promise<void> {
300300
// `fs.linkSync` has some issues on macOS for Godot executable
301301
// it does not create symlink at all, it copies whole file
302302
// and corrupts it a way that Godot gets killed by kernel (Killed: 9)
303-
if (process.platform === "darwin") {
303+
if (process.platform === 'darwin') {
304304
child_process.execSync(`ln -s "${godotExecutable}" "${godotAlias}"`)
305305
} else {
306306
fs.linkSync(godotExecutable, godotAlias)
@@ -332,4 +332,4 @@ async function run(platform: Platform): Promise<void> {
332332
}
333333
}
334334

335-
run(getPlatform(process.platform))
335+
void run(getPlatform(process.platform))

src/utils.ts

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as core from '@actions/core'
2-
import * as fs from 'fs'
32
import normalize from 'normalize-path'
4-
import * as os from 'os'
5-
import * as path from 'path'
3+
import * as fs from 'node:fs'
4+
import * as path from 'node:path'
5+
import * as os from 'node:os'
66

77
export interface Platform {
88
/** Godot installation filename suffix. */
@@ -33,14 +33,34 @@ export class Linux implements Platform {
3333
'.local/share/godot'
3434
)
3535

36+
private readonly arch: string
37+
38+
constructor(osArch: ReturnType<typeof os.arch>) {
39+
// According to: https://github.com/godotengine/godot-builds/releases
40+
const toGodotArchMapping: Record<string, string | undefined> = {
41+
arm64: 'arm64',
42+
x64: 'x86_64'
43+
}
44+
45+
const mappedArch = toGodotArchMapping[osArch]
46+
47+
if (mappedArch === undefined) {
48+
throw new Error(
49+
`⛔Unsupported Linux arch: ${osArch}, supported: arm64, x64`
50+
)
51+
}
52+
53+
this.arch = mappedArch
54+
}
55+
3656
godotFilenameSuffix(useDotnet: boolean): string {
3757
if (useDotnet) {
38-
return '_mono_linux_x86_64'
58+
return `_mono_linux_${this.arch}`
3959
}
40-
return '_linux.x86_64'
60+
return `_linux.${this.arch}`
4161
}
4262
isGodotExecutable(basename: string): boolean {
43-
return basename.toLowerCase().endsWith('x86_64')
63+
return basename.toLowerCase().endsWith(this.arch)
4464
}
4565
getUnzippedPath(
4666
installationDir: string,
@@ -56,14 +76,34 @@ export class Windows implements Platform {
5676
path.join(os.homedir(), '\\AppData\\Roaming\\Godot')
5777
)
5878

79+
private readonly arch: string
80+
81+
constructor(osArch: ReturnType<typeof os.arch>) {
82+
// According to: https://github.com/godotengine/godot-builds/releases
83+
const toGodotArchMapping: Record<string, string | undefined> = {
84+
arm64: 'windows_arm64',
85+
x64: 'win64'
86+
}
87+
88+
const mappedArch = toGodotArchMapping[osArch]
89+
90+
if (mappedArch === undefined) {
91+
throw new Error(
92+
`⛔Unsupported Windows arch: ${osArch}, supported: arm64, x64`
93+
)
94+
}
95+
96+
this.arch = mappedArch
97+
}
98+
5999
godotFilenameSuffix(useDotnet: boolean): string {
60100
if (useDotnet) {
61-
return '_mono_win64'
101+
return `_mono_${this.arch}`
62102
}
63-
return '_win64.exe'
103+
return `_${this.arch}.exe`
64104
}
65105
isGodotExecutable(basename: string): boolean {
66-
return basename.toLowerCase().endsWith('_win64.exe')
106+
return basename.toLowerCase().endsWith(`_${this.arch}.exe`)
67107
}
68108
getUnzippedPath(
69109
installationDir: string,
@@ -249,14 +289,14 @@ export function getGodotFilenameFromVersionString(
249289
return getGodotFilename(parseVersion(versionString), platform, useDotnet)
250290
}
251291

252-
export function getPlatform(processPlatform: NodeJS.Platform): Platform {
292+
export function getPlatform(processPlatform: NodeJS.Platform, arch = os.arch()): Platform {
253293
switch (processPlatform) {
254294
case 'linux':
255295
core.info('🐧 Running on Linux')
256-
return new Linux()
296+
return new Linux(arch)
257297
case 'win32':
258298
core.info('⧉ Running on Windows')
259-
return new Windows()
299+
return new Windows(arch)
260300
case 'darwin':
261301
core.info('🍏 Running on macOS')
262302
return new MacOS()
@@ -285,7 +325,7 @@ export async function findExecutablesRecursively(
285325
} else {
286326
// Test if file is executable. GodotSharp.dll is always considered an
287327
// executable.
288-
let isExecutable = file.name === 'GodotSharp.dll' ? true : false
328+
let isExecutable = file.name === 'GodotSharp.dll'
289329
if (!isExecutable) {
290330
if (platform instanceof Windows) {
291331
// fs.constants.X_OK doesn't seem to work on Windows.

0 commit comments

Comments
 (0)