diff --git a/action.yml b/action.yml index 454297a..15c4cfb 100644 --- a/action.yml +++ b/action.yml @@ -11,7 +11,7 @@ inputs: Godot 4 version: e.g., 4.0.0-beta1, 4.0.0-beta.16, 4.0.0, etc. Must include major, minor, and patch (additional pre-release label is optional). Specify `global` or `global.json` to use the version from the project's global.json file. ```yaml - - uses: chickensoft/setup-godot-action@v1 + - uses: Mimyr-Games-LTD/setup-godot-custom@v1 with: version: global ``` @@ -37,6 +37,18 @@ inputs: ``` required: true + custom_url: + description: >- + Optional custom URL to download a custom Godot build. If set, the action will + download and use this build instead of determining a version from `version`. + Example: + ```yaml + - uses: Mimyr-Games-LTD/setup-godot-custom@v1 + with: + custom_url: 'https://example.com/my_custom_godot_build.zip' + ``` + required: false + default: '' path: description: >- Path to install Godot to, relative to the current working directory of diff --git a/package-lock.json b/package-lock.json index 64565ae..baecbb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "normalize-path": "^3.0.0" }, "devDependencies": { - "@types/node": "^20.5.7", + "@types/node": "^20.17.10", "@typescript-eslint/parser": "^5.62.0", "@vercel/ncc": "^0.36.1", "eslint": "^8.48.0", @@ -26,7 +26,7 @@ "js-yaml": "^4.1.0", "prettier": "^2.8.8", "ts-jest": "^29.1.0", - "typescript": "^5.2.0" + "typescript": "^5.2.2" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1650,11 +1650,12 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", - "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", + "version": "20.17.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.10.tgz", + "integrity": "sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==", + "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/@types/node-fetch": { @@ -6680,9 +6681,10 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "license": "MIT" }, "node_modules/update-browserslist-db": { "version": "1.0.10", @@ -8265,11 +8267,11 @@ "dev": true }, "@types/node": { - "version": "20.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", - "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", + "version": "20.17.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.10.tgz", + "integrity": "sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==", "requires": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "@types/node-fetch": { @@ -11895,9 +11897,9 @@ } }, "undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, "update-browserslist-db": { "version": "1.0.10", diff --git a/package.json b/package.json index 9afb8e5..5d5b818 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "normalize-path": "^3.0.0" }, "devDependencies": { - "@types/node": "^20.5.7", + "@types/node": "^20.17.10", "@typescript-eslint/parser": "^5.62.0", "@vercel/ncc": "^0.36.1", "eslint": "^8.48.0", diff --git a/src/main.ts b/src/main.ts index 4ad36b1..f9a7b6a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,11 +21,12 @@ async function run(platform: Platform): Promise { .getInput('downloads-path') .replace(/\s/g, '') let version = core.getInput('version').replace(/\s/g, '') + const customUrl = core.getInput('custom_url').trim() const useDotnet = core.getBooleanInput('use-dotnet') const binRelativePath = core.getInput('bin-path').replace(/\s/g, '') const godotSharpRelease = core.getBooleanInput('godot-sharp-release') const checkoutDirectory = process.env['GITHUB_WORKSPACE'] ?? '' - const includeTemplates = core.getBooleanInput('include-templates') + let includeTemplates = core.getBooleanInput('include-templates') const useCache = core.getBooleanInput('cache') const userDir = os.homedir() @@ -61,13 +62,38 @@ async function run(platform: Platform): Promise { version = globalJson['msbuild-sdks']['Godot.NET.Sdk'] ?? '' } - // Compute derived information from Godot version. - const versionName = getGodotFilenameFromVersionString( - version, - platform, - useDotnet - ) - const godotUrl = getGodotUrl(version, platform, useDotnet, false) + // Определяем значения для godotUrl, versionName и exportTemplateUrl + let versionName = '' + let godotUrl = '' + let exportTemplateUrl = '' + + if (customUrl.length > 0) { + // Если задан customUrl, используем его вместо вычислений по версии + core.info(`😎 Using custom Godot build from ${customUrl}`) + versionName = 'custom_godot' + godotUrl = customUrl + + // При использовании customUrl определить экспортные шаблоны нельзя (по умолчанию их нет) + // Можно либо запретить, либо проигнорировать includeTemplates. + // Тут просто отключаем. + if (includeTemplates) { + core.info(`⚠️ Templates are not supported with custom builds. Skipping templates.`) + } + includeTemplates = false + exportTemplateUrl = '' + } else { + // Стандартная логика + versionName = getGodotFilenameFromVersionString( + version, + platform, + useDotnet + ) + godotUrl = getGodotUrl(version, platform, useDotnet, false) + exportTemplateUrl = includeTemplates + ? getGodotUrl(version, platform, useDotnet, true) + : '' + } + const godotDownloadPath = path.join(downloadsDir, `${versionName}.zip`) const godotInstallationPath = platform.getUnzippedPath( installationDir, @@ -75,10 +101,6 @@ async function run(platform: Platform): Promise { useDotnet ) const binDir = path.join(userDir, binRelativePath) - - const exportTemplateUrl = includeTemplates - ? getGodotUrl(version, platform, useDotnet, true) - : '' const exportTemplatePath = includeTemplates ? getExportTemplatePath(version, platform, useDotnet) : '' @@ -174,7 +196,7 @@ async function run(platform: Platform): Promise { core.info(`✅ Files shown`) core.endGroup() - if (includeTemplates) { + if (includeTemplates && exportTemplateUrl) { core.startGroup( `📥 Downloading Export Templates to ${exportTemplateDownloadPath}...` ) @@ -210,10 +232,7 @@ async function run(platform: Platform): Promise { exportTemplatePath ) core.info( - `✅ ${path.join( - path.dirname(exportTemplateExtractedPath), - 'templates' - )} moved to ${exportTemplatePath}` + `✅ templates moved to ${exportTemplatePath}` ) core.endGroup() diff --git a/src/utils.ts b/src/utils.ts index 93831aa..318442a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -285,7 +285,7 @@ export async function findExecutablesRecursively( } else { // Test if file is executable. GodotSharp.dll is always considered an // executable. - let isExecutable = file.name === 'GodotSharp.dll' ? true : false + let isExecutable = file.name === 'GodotSharp.dll' if (!isExecutable) { if (platform instanceof Windows) { // fs.constants.X_OK doesn't seem to work on Windows.