mirror of
https://github.com/chickensoft-games/setup-godot.git
synced 2025-08-14 12:55:08 +00:00
feat: allow dotnet to be specified (#21)
* feat: allow dotnet to be specified * docs: update readme * fix: optimize test workflow
This commit is contained in:
parent
1be00b61d4
commit
41ce0e3de8
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@ -8,7 +8,7 @@ on: # rebuild any PRs and main branch changes
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: 🧪 Test on ${{ matrix.os }}
|
||||
name: 🧪 Test on ${{ matrix.os }}, .NET=${{ matrix.use-dotnet }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
# Don't cancel other OS runners if one fails.
|
||||
@ -16,6 +16,7 @@ jobs:
|
||||
matrix:
|
||||
# Put the operating systems you want to run on here.
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
use-dotnet: [false, true]
|
||||
env:
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||
DOTNET_NOLOGO: true
|
||||
@ -28,6 +29,7 @@ jobs:
|
||||
name: 🧾 Checkout
|
||||
|
||||
- uses: actions/setup-dotnet@v3
|
||||
if: ${{ matrix.use-dotnet }}
|
||||
name: 💽 Setup .NET SDK
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
@ -38,8 +40,13 @@ jobs:
|
||||
# Version must include major, minor, and patch, and be >= 4.0.0
|
||||
# Pre-release label is optional.
|
||||
version: 4.0.0
|
||||
use-dotnet: ${{ matrix.use-dotnet }}
|
||||
|
||||
- name: 🔬 Verify Setup
|
||||
- name: 🔬 Verify Dotnet
|
||||
if: ${{ matrix.use-dotnet }}
|
||||
run: |
|
||||
dotnet --version
|
||||
|
||||
- name: 🔬 Verify Godot
|
||||
run: |
|
||||
godot --version
|
||||
|
18
.vscode/launch.json
vendored
Normal file
18
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Jest Tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
||||
"args": [
|
||||
"--runInBand",
|
||||
"--no-cache",
|
||||
"--watch"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
}
|
||||
]
|
||||
}
|
21
README.md
21
README.md
@ -1,11 +1,12 @@
|
||||
# Setup Godot
|
||||
# 🤖 Setup Godot
|
||||
|
||||
[![Chickensoft Badge][chickensoft-badge]][chickensoft-website] [![Discord][discord-badge]][discord]
|
||||
[![Chickensoft Badge][chickensoft-badge]][chickensoft-website] [![Discord][discord-badge]][discord] [![Read the docs][read-the-docs-badge]][docs]
|
||||
|
||||
Setup Godot for use with .NET on macOS, Windows, and Linux CI/CD runners.
|
||||
Setup Godot for use with (or without) .NET on macOS, Windows, and Linux CI/CD runners.
|
||||
|
||||
- ✅ Godot 4.x
|
||||
- ✅ C# supported using .NET version of Godot.
|
||||
- ✅ Versions **without** .NET are also supported.
|
||||
- ✅ Installs Godot directly on the CI/CD runner.
|
||||
- ✅ Caches Godot installation for speedier workflows.
|
||||
- ✅ Adds environment variables (`GODOT4`, `GODOT`) to the system path.
|
||||
@ -59,6 +60,8 @@ jobs:
|
||||
# Version must include major, minor, and patch, and be >= 4.0.0
|
||||
# Pre-release label is optional.
|
||||
version: 4.0.0-beta16 # also valid: 4.0.0.rc1 or 4.0.0, etc
|
||||
# Use .NET-enabled version of Godot (the default is also true).
|
||||
use-dotnet: true
|
||||
|
||||
- name: 🔬 Verify Setup
|
||||
run: |
|
||||
@ -74,10 +77,14 @@ jobs:
|
||||
# Do whatever you want!
|
||||
```
|
||||
|
||||
<!-- Links -->
|
||||
## Inputs
|
||||
|
||||
<!-- Header -->
|
||||
[chickensoft-badge]: https://chickensoft.games/images/chickensoft/chickensoft_badge.svg
|
||||
See [action.yml][action] for information about the action's inputs.
|
||||
|
||||
[chickensoft-badge]: https://raw.githubusercontent.com/chickensoft-games/chickensoft_site/main/static/img/badges/chickensoft_badge.svg
|
||||
[chickensoft-website]: https://chickensoft.games
|
||||
[discord-badge]: https://raw.githubusercontent.com/chickensoft-games/chickensoft_site/main/static/img/badges/discord_badge.svg
|
||||
[discord]: https://discord.gg/gSjaPgMmYW
|
||||
[discord-badge]: https://img.shields.io/badge/Chickensoft%20Discord-%237289DA.svg?style=flat&logo=discord&logoColor=white
|
||||
[read-the-docs-badge]: https://raw.githubusercontent.com/chickensoft-games/chickensoft_site/main/static/img/badges/read_the_docs_badge.svg
|
||||
[docs]: https://chickensoft.games/docs
|
||||
[action]: ./action.yml
|
||||
|
@ -28,48 +28,77 @@ describe('parseVersion', () => {
|
||||
})
|
||||
|
||||
describe('getGodotUrl', () => {
|
||||
test('4.0.0-beta1', () => {
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('win32'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('darwin'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_macos.universal.zip'
|
||||
)
|
||||
describe('useDotnet = true', () => {
|
||||
test('4.0.0-beta1', () => {
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('win32'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('darwin'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
test('4.0.0-beta.16', () => {
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('win32'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('darwin'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
test('4.0.0-beta8', () => {
|
||||
expect(getGodotUrl('4.0.0-beta8', getPlatform('linux'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta8', getPlatform('win32'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta8', getPlatform('darwin'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
test('4.0.0', () => {
|
||||
expect(getGodotUrl('4.0.0', getPlatform('linux'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0', getPlatform('win32'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0', getPlatform('darwin'), true)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
})
|
||||
test('4.0.0-beta.16', () => {
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('win32'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('darwin'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
test('4.0.0-beta8', () => {
|
||||
expect(getGodotUrl('4.0.0-beta8', getPlatform('linux'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta8', getPlatform('win32'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta8', getPlatform('darwin'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
test('4.0.0', () => {
|
||||
expect(getGodotUrl('4.0.0', getPlatform('linux'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_linux_x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0', getPlatform('win32'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_win64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0', getPlatform('darwin'))).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_macos.universal.zip'
|
||||
)
|
||||
|
||||
describe('useDotnet = false', () => {
|
||||
test('4.0.0-beta1', () => {
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), false)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_linux.x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('win32'), false)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_win64.exe.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta1', getPlatform('darwin'), false)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
test('4.0.0-beta.16', () => {
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'), false)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_linux.x86_64.zip'
|
||||
)
|
||||
expect(getGodotUrl('4.0.0-beta.16', getPlatform('win32'), false)).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_win64.exe.zip'
|
||||
)
|
||||
expect(
|
||||
getGodotUrl('4.0.0-beta.16', getPlatform('darwin'), false)
|
||||
).toEqual(
|
||||
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_macos.universal.zip'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -33,6 +33,10 @@ inputs:
|
||||
Whether to use the release or debug version of GodotSharp.dll. The
|
||||
appropriate version will be symlinked in bin-path.
|
||||
default: 'false'
|
||||
use-dotnet:
|
||||
description: >-
|
||||
True to use the .NET-enabled version of Godot that enables C#, false to use the default version.
|
||||
default: 'true'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"words": [
|
||||
"Chickensoft",
|
||||
"godotsharp",
|
||||
"NOLOGO",
|
||||
"norelease",
|
||||
"OPTOUT",
|
||||
|
73
dist/index.js
generated
vendored
73
dist/index.js
generated
vendored
@ -58,21 +58,23 @@ function run(platform = undefined) {
|
||||
.getInput('downloads-path')
|
||||
.replace(/\s/g, '');
|
||||
const version = core.getInput('version').replace(/\s/g, '');
|
||||
const useDotnet = core.getBooleanInput('use-dotnet');
|
||||
const binRelativePath = core.getInput('bin-path').replace(/\s/g, '');
|
||||
const godotSharpRelease = core.getBooleanInput('godot-sharp-release');
|
||||
// Compute derived information
|
||||
const userDir = os.homedir();
|
||||
const downloadsDir = path_1.default.join(userDir, downloadsRelativePath);
|
||||
const installationDir = path_1.default.join(userDir, pathRelative);
|
||||
const versionName = (0, utils_1.getGodotFilenameFromVersionString)(version, platform);
|
||||
const godotUrl = (0, utils_1.getGodotUrl)(version, platform);
|
||||
const versionName = (0, utils_1.getGodotFilenameFromVersionString)(version, platform, useDotnet);
|
||||
const godotUrl = (0, utils_1.getGodotUrl)(version, platform, useDotnet);
|
||||
const godotDownloadPath = path_1.default.join(downloadsDir, `${versionName}.zip`);
|
||||
const godotInstallationPath = platform.getUnzippedPath(installationDir, versionName);
|
||||
const godotInstallationPath = platform.getUnzippedPath(installationDir, versionName, useDotnet);
|
||||
const binDir = path_1.default.join(userDir, binRelativePath);
|
||||
// Log values
|
||||
core.startGroup('🤖 Godot Action Inputs');
|
||||
core.info(`🤖 Godot version: ${version}`);
|
||||
core.info(`🤖 Godot version name: ${versionName}`);
|
||||
core.info(`🟣 Use .NET: ${useDotnet}`);
|
||||
core.info(`🤖 Godot download url: ${godotUrl}`);
|
||||
core.info(`🧑💼 User directory: ${userDir}`);
|
||||
core.info(`🌏 Downloads directory: ${downloadsDir}`);
|
||||
@ -141,12 +143,14 @@ function run(platform = undefined) {
|
||||
if (!godotExecutable) {
|
||||
throw new Error('🚨 No Godot executable found!');
|
||||
}
|
||||
if (!godotSharp) {
|
||||
if (!godotSharp && useDotnet) {
|
||||
throw new Error('🚨 No GodotSharp.dll found!');
|
||||
}
|
||||
core.startGroup(`🚀 Resolve Godot Executables:`);
|
||||
core.info(`🚀 Godot executable found at ${godotExecutable}`);
|
||||
core.info(`🚀 GodotSharp.dll found at ${godotSharp}`);
|
||||
if (useDotnet) {
|
||||
core.info(`🚀 GodotSharp.dll found at ${godotSharp}`);
|
||||
}
|
||||
core.endGroup();
|
||||
// Add bin directory to PATH
|
||||
core.startGroup(`🔦 Update PATH...`);
|
||||
@ -156,15 +160,16 @@ function run(platform = undefined) {
|
||||
core.endGroup();
|
||||
// Create symlink to Godot executable
|
||||
const godotAlias = path_1.default.join(binDir, 'godot');
|
||||
const godotSharpDirAlias = path_1.default.join(binDir, 'GodotSharp');
|
||||
core.startGroup(`🔗 Creating symlinks to executables...`);
|
||||
fs.linkSync(godotExecutable, godotAlias);
|
||||
core.info(`✅ Symlink to Godot created`);
|
||||
// Create symlink to GodotSharp directory
|
||||
const godotSharpDir = path_1.default.join(path_1.default.dirname(godotSharp), '../..');
|
||||
// fs.mkdirSync(godotSharpDirAlias, {recursive: true})
|
||||
fs.symlinkSync(godotSharpDir, godotSharpDirAlias);
|
||||
core.info(`✅ Symlink to GodotSharp created at ${godotSharpDirAlias}`);
|
||||
const godotSharpDirAlias = path_1.default.join(binDir, 'GodotSharp');
|
||||
if (useDotnet) {
|
||||
// Create symlink to GodotSharp directory
|
||||
const godotSharpDir = path_1.default.join(path_1.default.dirname(godotSharp), '../..');
|
||||
fs.symlinkSync(godotSharpDir, godotSharpDirAlias);
|
||||
core.info(`✅ Symlink to GodotSharp created at ${godotSharpDirAlias}`);
|
||||
}
|
||||
core.endGroup();
|
||||
// Add environment variables
|
||||
core.startGroup(`🔧 Adding environment variables...`);
|
||||
@ -233,38 +238,44 @@ const core = __importStar(__nccwpck_require__(2186));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
class Linux {
|
||||
constructor() {
|
||||
this.godotFilenameSuffix = '_mono_linux_x86_64';
|
||||
godotFilenameSuffix(useDotnet) {
|
||||
if (useDotnet) {
|
||||
return '_mono_linux_x86_64';
|
||||
}
|
||||
return '_linux.x86_64';
|
||||
}
|
||||
isGodotExecutable(basename) {
|
||||
return basename.toLowerCase().endsWith('x86_64');
|
||||
}
|
||||
getUnzippedPath(installationDir, versionName) {
|
||||
getUnzippedPath(installationDir, versionName, useDotnet) {
|
||||
return path_1.default.join(installationDir, versionName);
|
||||
}
|
||||
}
|
||||
exports.Linux = Linux;
|
||||
class Windows {
|
||||
constructor() {
|
||||
this.godotFilenameSuffix = '_mono_win64';
|
||||
godotFilenameSuffix(useDotnet) {
|
||||
if (useDotnet) {
|
||||
return '_mono_win64';
|
||||
}
|
||||
return '_win64.exe';
|
||||
}
|
||||
isGodotExecutable(basename) {
|
||||
return basename.toLowerCase().endsWith('_win64.exe');
|
||||
}
|
||||
getUnzippedPath(installationDir, versionName) {
|
||||
getUnzippedPath(installationDir, versionName, useDotnet) {
|
||||
return path_1.default.join(installationDir, versionName);
|
||||
}
|
||||
}
|
||||
exports.Windows = Windows;
|
||||
class MacOS {
|
||||
constructor() {
|
||||
this.godotFilenameSuffix = '_mono_macos.universal';
|
||||
godotFilenameSuffix(useDotnet) {
|
||||
return `${useDotnet ? '_mono' : ''}_macos.universal`;
|
||||
}
|
||||
isGodotExecutable(basename) {
|
||||
return basename.toLowerCase() === 'godot';
|
||||
}
|
||||
getUnzippedPath(installationDir, versionName) {
|
||||
return path_1.default.join(installationDir, 'Godot_mono.app');
|
||||
getUnzippedPath(installationDir, versionName, useDotnet) {
|
||||
return path_1.default.join(installationDir, `Godot${useDotnet ? '_mono' : ''}.app`);
|
||||
}
|
||||
}
|
||||
exports.MacOS = MacOS;
|
||||
@ -293,15 +304,16 @@ exports.parseVersion = parseVersion;
|
||||
* Returns the Godot download url for the given version and platform.
|
||||
* @param versionString Version string.
|
||||
* @param platform Current platform instance.
|
||||
* @param useDotnet True to use the .NET-enabled version of Godot.
|
||||
* @returns Godot binary download url.
|
||||
*/
|
||||
function getGodotUrl(versionString, platform) {
|
||||
function getGodotUrl(versionString, platform, useDotnet) {
|
||||
const version = parseVersion(versionString);
|
||||
const major = version.major;
|
||||
const minor = version.minor;
|
||||
const patch = version.patch;
|
||||
const label = version.label.replace('.', '');
|
||||
const filename = getGodotFilename(version, platform);
|
||||
const filename = getGodotFilename(version, platform, useDotnet);
|
||||
let url = `${GODOT_URL_PREFIX + major}.${minor}`;
|
||||
if (patch !== '' && patch !== '0') {
|
||||
url += `.${patch}`;
|
||||
@ -310,11 +322,16 @@ function getGodotUrl(versionString, platform) {
|
||||
if (label !== '') {
|
||||
url += `${label}/`;
|
||||
}
|
||||
url += `mono/${filename}.zip`;
|
||||
if (useDotnet) {
|
||||
url += `mono/${filename}.zip`;
|
||||
}
|
||||
else {
|
||||
url += `${filename}.zip`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
exports.getGodotUrl = getGodotUrl;
|
||||
function getGodotFilename(version, platform) {
|
||||
function getGodotFilename(version, platform, useDotnet) {
|
||||
const major = version.major;
|
||||
const minor = version.minor;
|
||||
const patch = version.patch;
|
||||
@ -332,11 +349,11 @@ function getGodotFilename(version, platform) {
|
||||
else {
|
||||
filename += '-stable';
|
||||
}
|
||||
return filename + platform.godotFilenameSuffix;
|
||||
return filename + platform.godotFilenameSuffix(useDotnet);
|
||||
}
|
||||
exports.getGodotFilename = getGodotFilename;
|
||||
function getGodotFilenameFromVersionString(versionString, platform) {
|
||||
return getGodotFilename(parseVersion(versionString), platform);
|
||||
function getGodotFilenameFromVersionString(versionString, platform, useDotnet) {
|
||||
return getGodotFilename(parseVersion(versionString), platform, useDotnet);
|
||||
}
|
||||
exports.getGodotFilenameFromVersionString = getGodotFilenameFromVersionString;
|
||||
function getPlatform(processPlatform) {
|
||||
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
32
src/main.ts
32
src/main.ts
@ -22,6 +22,7 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
|
||||
.getInput('downloads-path')
|
||||
.replace(/\s/g, '')
|
||||
const version = core.getInput('version').replace(/\s/g, '')
|
||||
const useDotnet = core.getBooleanInput('use-dotnet')
|
||||
const binRelativePath = core.getInput('bin-path').replace(/\s/g, '')
|
||||
const godotSharpRelease = core.getBooleanInput('godot-sharp-release')
|
||||
|
||||
@ -29,12 +30,17 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
|
||||
const userDir = os.homedir()
|
||||
const downloadsDir = path.join(userDir, downloadsRelativePath)
|
||||
const installationDir = path.join(userDir, pathRelative)
|
||||
const versionName = getGodotFilenameFromVersionString(version, platform)
|
||||
const godotUrl = getGodotUrl(version, platform)
|
||||
const versionName = getGodotFilenameFromVersionString(
|
||||
version,
|
||||
platform,
|
||||
useDotnet
|
||||
)
|
||||
const godotUrl = getGodotUrl(version, platform, useDotnet)
|
||||
const godotDownloadPath = path.join(downloadsDir, `${versionName}.zip`)
|
||||
const godotInstallationPath = platform.getUnzippedPath(
|
||||
installationDir,
|
||||
versionName
|
||||
versionName,
|
||||
useDotnet
|
||||
)
|
||||
const binDir = path.join(userDir, binRelativePath)
|
||||
|
||||
@ -42,6 +48,7 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
|
||||
core.startGroup('🤖 Godot Action Inputs')
|
||||
core.info(`🤖 Godot version: ${version}`)
|
||||
core.info(`🤖 Godot version name: ${versionName}`)
|
||||
core.info(`🟣 Use .NET: ${useDotnet}`)
|
||||
core.info(`🤖 Godot download url: ${godotUrl}`)
|
||||
core.info(`🧑💼 User directory: ${userDir}`)
|
||||
core.info(`🌏 Downloads directory: ${downloadsDir}`)
|
||||
@ -139,13 +146,15 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
|
||||
throw new Error('🚨 No Godot executable found!')
|
||||
}
|
||||
|
||||
if (!godotSharp) {
|
||||
if (!godotSharp && useDotnet) {
|
||||
throw new Error('🚨 No GodotSharp.dll found!')
|
||||
}
|
||||
|
||||
core.startGroup(`🚀 Resolve Godot Executables:`)
|
||||
core.info(`🚀 Godot executable found at ${godotExecutable}`)
|
||||
core.info(`🚀 GodotSharp.dll found at ${godotSharp}`)
|
||||
if (useDotnet) {
|
||||
core.info(`🚀 GodotSharp.dll found at ${godotSharp}`)
|
||||
}
|
||||
core.endGroup()
|
||||
|
||||
// Add bin directory to PATH
|
||||
@ -157,15 +166,16 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
|
||||
|
||||
// Create symlink to Godot executable
|
||||
const godotAlias = path.join(binDir, 'godot')
|
||||
const godotSharpDirAlias = path.join(binDir, 'GodotSharp')
|
||||
core.startGroup(`🔗 Creating symlinks to executables...`)
|
||||
fs.linkSync(godotExecutable, godotAlias)
|
||||
core.info(`✅ Symlink to Godot created`)
|
||||
// Create symlink to GodotSharp directory
|
||||
const godotSharpDir = path.join(path.dirname(godotSharp), '../..')
|
||||
// fs.mkdirSync(godotSharpDirAlias, {recursive: true})
|
||||
fs.symlinkSync(godotSharpDir, godotSharpDirAlias)
|
||||
core.info(`✅ Symlink to GodotSharp created at ${godotSharpDirAlias}`)
|
||||
const godotSharpDirAlias = path.join(binDir, 'GodotSharp')
|
||||
if (useDotnet) {
|
||||
// Create symlink to GodotSharp directory
|
||||
const godotSharpDir = path.join(path.dirname(godotSharp), '../..')
|
||||
fs.symlinkSync(godotSharpDir, godotSharpDirAlias)
|
||||
core.info(`✅ Symlink to GodotSharp created at ${godotSharpDirAlias}`)
|
||||
}
|
||||
core.endGroup()
|
||||
|
||||
// Add environment variables
|
||||
|
71
src/utils.ts
71
src/utils.ts
@ -4,7 +4,7 @@ import path from 'path'
|
||||
|
||||
export interface Platform {
|
||||
/** Godot installation filename suffix. */
|
||||
godotFilenameSuffix: string
|
||||
godotFilenameSuffix(useDotnet: boolean): string
|
||||
/**
|
||||
* Returns true if the given path is most likely the Godot executable for
|
||||
* the platform.
|
||||
@ -16,36 +16,64 @@ export interface Platform {
|
||||
* @param installationDir Installation directory.
|
||||
* @param versionName Version name.
|
||||
*/
|
||||
getUnzippedPath(installationDir: string, versionName: string): string
|
||||
getUnzippedPath(
|
||||
installationDir: string,
|
||||
versionName: string,
|
||||
useDotnet: boolean
|
||||
): string
|
||||
}
|
||||
|
||||
export class Linux implements Platform {
|
||||
godotFilenameSuffix = '_mono_linux_x86_64'
|
||||
godotFilenameSuffix(useDotnet: boolean): string {
|
||||
if (useDotnet) {
|
||||
return '_mono_linux_x86_64'
|
||||
}
|
||||
return '_linux.x86_64'
|
||||
}
|
||||
isGodotExecutable(basename: string): boolean {
|
||||
return basename.toLowerCase().endsWith('x86_64')
|
||||
}
|
||||
getUnzippedPath(installationDir: string, versionName: string): string {
|
||||
getUnzippedPath(
|
||||
installationDir: string,
|
||||
versionName: string,
|
||||
useDotnet: boolean
|
||||
): string {
|
||||
return path.join(installationDir, versionName)
|
||||
}
|
||||
}
|
||||
|
||||
export class Windows implements Platform {
|
||||
godotFilenameSuffix = '_mono_win64'
|
||||
godotFilenameSuffix(useDotnet: boolean): string {
|
||||
if (useDotnet) {
|
||||
return '_mono_win64'
|
||||
}
|
||||
return '_win64.exe'
|
||||
}
|
||||
isGodotExecutable(basename: string): boolean {
|
||||
return basename.toLowerCase().endsWith('_win64.exe')
|
||||
}
|
||||
getUnzippedPath(installationDir: string, versionName: string): string {
|
||||
getUnzippedPath(
|
||||
installationDir: string,
|
||||
versionName: string,
|
||||
useDotnet: boolean
|
||||
): string {
|
||||
return path.join(installationDir, versionName)
|
||||
}
|
||||
}
|
||||
|
||||
export class MacOS implements Platform {
|
||||
godotFilenameSuffix = '_mono_macos.universal'
|
||||
godotFilenameSuffix(useDotnet: boolean): string {
|
||||
return `${useDotnet ? '_mono' : ''}_macos.universal`
|
||||
}
|
||||
isGodotExecutable(basename: string): boolean {
|
||||
return basename.toLowerCase() === 'godot'
|
||||
}
|
||||
getUnzippedPath(installationDir: string, versionName: string): string {
|
||||
return path.join(installationDir, 'Godot_mono.app')
|
||||
getUnzippedPath(
|
||||
installationDir: string,
|
||||
versionName: string,
|
||||
useDotnet: boolean
|
||||
): string {
|
||||
return path.join(installationDir, `Godot${useDotnet ? '_mono' : ''}.app`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,16 +118,21 @@ export function parseVersion(version: string): SemanticVersion {
|
||||
* Returns the Godot download url for the given version and platform.
|
||||
* @param versionString Version string.
|
||||
* @param platform Current platform instance.
|
||||
* @param useDotnet True to use the .NET-enabled version of Godot.
|
||||
* @returns Godot binary download url.
|
||||
*/
|
||||
export function getGodotUrl(versionString: string, platform: Platform): string {
|
||||
export function getGodotUrl(
|
||||
versionString: string,
|
||||
platform: Platform,
|
||||
useDotnet: boolean
|
||||
): string {
|
||||
const version = parseVersion(versionString)
|
||||
const major = version.major
|
||||
const minor = version.minor
|
||||
const patch = version.patch
|
||||
const label = version.label.replace('.', '')
|
||||
|
||||
const filename = getGodotFilename(version, platform)
|
||||
const filename = getGodotFilename(version, platform, useDotnet)
|
||||
|
||||
let url = `${GODOT_URL_PREFIX + major}.${minor}`
|
||||
if (patch !== '' && patch !== '0') {
|
||||
@ -109,14 +142,19 @@ export function getGodotUrl(versionString: string, platform: Platform): string {
|
||||
if (label !== '') {
|
||||
url += `${label}/`
|
||||
}
|
||||
url += `mono/${filename}.zip`
|
||||
if (useDotnet) {
|
||||
url += `mono/${filename}.zip`
|
||||
} else {
|
||||
url += `${filename}.zip`
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
export function getGodotFilename(
|
||||
version: SemanticVersion,
|
||||
platform: Platform
|
||||
platform: Platform,
|
||||
useDotnet: boolean
|
||||
): string {
|
||||
const major = version.major
|
||||
const minor = version.minor
|
||||
@ -137,14 +175,15 @@ export function getGodotFilename(
|
||||
filename += '-stable'
|
||||
}
|
||||
|
||||
return filename + platform.godotFilenameSuffix
|
||||
return filename + platform.godotFilenameSuffix(useDotnet)
|
||||
}
|
||||
|
||||
export function getGodotFilenameFromVersionString(
|
||||
versionString: string,
|
||||
platform: Platform
|
||||
platform: Platform,
|
||||
useDotnet: boolean
|
||||
): string {
|
||||
return getGodotFilename(parseVersion(versionString), platform)
|
||||
return getGodotFilename(parseVersion(versionString), platform, useDotnet)
|
||||
}
|
||||
|
||||
export function getPlatform(processPlatform: NodeJS.Platform): Platform {
|
||||
|
Loading…
x
Reference in New Issue
Block a user