feat: add export templates

This commit is contained in:
Adriano Orioli 2023-03-30 00:08:11 +02:00 committed by GitHub
parent 41ce0e3de8
commit 9f83926bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 355 additions and 59 deletions

1
.gitattributes vendored
View File

@ -1 +1,2 @@
dist/** -diff linguist-generated=true dist/** -diff linguist-generated=true
* text=auto

View File

@ -7,8 +7,6 @@ name: Check dist/
on: on:
push: push:
branches:
- main
paths-ignore: paths-ignore:
- '**.md' - '**.md'
pull_request: pull_request:
@ -46,7 +44,7 @@ jobs:
id: diff id: diff
# If index.js was different than expected, upload the expected version as an artifact # If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }} if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with: with:
name: dist name: dist

View File

@ -2,9 +2,6 @@ name: 'build-test'
on: # rebuild any PRs and main branch changes on: # rebuild any PRs and main branch changes
pull_request: pull_request:
push: push:
branches:
- main
- 'releases/*'
jobs: jobs:
tests: tests:

View File

@ -1,6 +1,8 @@
import {describe, expect, test} from '@jest/globals' import {describe, expect, test} from '@jest/globals'
import path from 'path'
import os from 'os'
import {getGodotUrl, getPlatform, parseVersion} from '../src/utils' import {getGodotUrl, getPlatform, parseVersion, getExportTemplatePath} from '../src/utils'
describe('parseVersion', () => { describe('parseVersion', () => {
test('parses valid godot versions', () => { test('parses valid godot versions', () => {
@ -30,75 +32,195 @@ describe('parseVersion', () => {
describe('getGodotUrl', () => { describe('getGodotUrl', () => {
describe('useDotnet = true', () => { describe('useDotnet = true', () => {
test('4.0.0-beta1', () => { test('4.0.0-beta1', () => {
expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), true)).toEqual( expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_linux_x86_64.zip' '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( expect(getGodotUrl('4.0.0-beta1', getPlatform('win32'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_win64.zip' '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( expect(getGodotUrl('4.0.0-beta1', getPlatform('darwin'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_macos.universal.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_macos.universal.zip'
) )
expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), true, true)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/mono/Godot_v4.0-beta1_mono_export_templates.tpz'
)
}) })
test('4.0.0-beta.16', () => { test('4.0.0-beta.16', () => {
expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'), true)).toEqual( expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_linux_x86_64.zip' '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( expect(getGodotUrl('4.0.0-beta.16', getPlatform('win32'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_win64.zip' '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( expect(getGodotUrl('4.0.0-beta.16', getPlatform('darwin'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_macos.universal.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/beta16/mono/Godot_v4.0-beta16_mono_macos.universal.zip'
) )
}) })
test('4.0.0-beta8', () => { test('4.0.0-beta8', () => {
expect(getGodotUrl('4.0.0-beta8', getPlatform('linux'), true)).toEqual( expect(getGodotUrl('4.0.0-beta8', getPlatform('linux'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_linux_x86_64.zip' '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( expect(getGodotUrl('4.0.0-beta8', getPlatform('win32'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_win64.zip' '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( expect(getGodotUrl('4.0.0-beta8', getPlatform('darwin'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_macos.universal.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/beta8/mono/Godot_v4.0-beta8_mono_macos.universal.zip'
) )
}) })
test('4.0.0', () => { test('4.0.0', () => {
expect(getGodotUrl('4.0.0', getPlatform('linux'), true)).toEqual( expect(getGodotUrl('4.0.0', getPlatform('linux'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_linux_x86_64.zip' '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( expect(getGodotUrl('4.0.0', getPlatform('win32'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_win64.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_win64.zip'
) )
expect(getGodotUrl('4.0.0', getPlatform('darwin'), true)).toEqual( expect(getGodotUrl('4.0.0', getPlatform('darwin'), true, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_macos.universal.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_macos.universal.zip'
) )
expect(getGodotUrl('4.0.0', getPlatform('linux'), true, true)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/mono/Godot_v4.0-stable_mono_export_templates.tpz'
)
})
test('3.5.2', () => {
expect(getGodotUrl('3.5.2', getPlatform('linux'), true, true)).toEqual(
'https://downloads.tuxfamily.org/godotengine/3.5.2/mono/Godot_v3.5.2-stable_mono_export_templates.tpz'
)
}) })
}) })
describe('useDotnet = false', () => { describe('useDotnet = false', () => {
test('4.0.0-beta1', () => { test('4.0.0-beta1', () => {
expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), false)).toEqual( expect(getGodotUrl('4.0.0-beta1', getPlatform('linux'), false, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_linux.x86_64.zip' '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( expect(getGodotUrl('4.0.0-beta1', getPlatform('win32'), false, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_win64.exe.zip' '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( expect(getGodotUrl('4.0.0-beta1', getPlatform('darwin'), false, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_macos.universal.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_macos.universal.zip'
) )
expect(getGodotUrl('4.0.0-beta1', getPlatform('darwin'), false, true)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta1/Godot_v4.0-beta1_export_templates.tpz'
)
}) })
test('4.0.0-beta.16', () => { test('4.0.0-beta.16', () => {
expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'), false)).toEqual( expect(getGodotUrl('4.0.0-beta.16', getPlatform('linux'), false, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_linux.x86_64.zip' '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( expect(getGodotUrl('4.0.0-beta.16', getPlatform('win32'), false, false)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_win64.exe.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_win64.exe.zip'
) )
expect( expect(
getGodotUrl('4.0.0-beta.16', getPlatform('darwin'), false) getGodotUrl('4.0.0-beta.16', getPlatform('darwin'), false, false)
).toEqual( ).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_macos.universal.zip' 'https://downloads.tuxfamily.org/godotengine/4.0/beta16/Godot_v4.0-beta16_macos.universal.zip'
) )
}) })
test('4.0.0', () => {
expect(getGodotUrl('4.0.0', getPlatform('linux'), false, true)).toEqual(
'https://downloads.tuxfamily.org/godotengine/4.0/Godot_v4.0-stable_export_templates.tpz'
)
})
test('3.5.2', () => {
expect(getGodotUrl('3.5.2', getPlatform('linux'), false, true)).toEqual(
'https://downloads.tuxfamily.org/godotengine/3.5.2/Godot_v3.5.2-stable_export_templates.tpz'
)
})
})
})
describe('getExportTemplatePath', () => {
describe('useDotnet = true', () => {
test('4.0.0-beta1', () => {
expect(getExportTemplatePath('4.0.0-beta1', getPlatform('linux'), true)).toEqual(
path.join(os.homedir(), '.local/share/godot/export_templates', '4.0.beta1.mono')
)
expect(getExportTemplatePath('4.0.0-beta1', getPlatform('win32'), true)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/export_templates', '4.0.beta1.mono')
)
expect(getExportTemplatePath('4.0.0-beta1', getPlatform('darwin'), true)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/export_templates', '4.0.beta1.mono')
)
})
test('4.0.0', () => {
expect(getExportTemplatePath('4.0.0', getPlatform('linux'), true)).toEqual(
path.join(os.homedir(), '.local/share/godot/export_templates', '4.0.stable.mono')
)
expect(getExportTemplatePath('4.0.0', getPlatform('win32'), true)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/export_templates', '4.0.stable.mono')
)
expect(getExportTemplatePath('4.0.0', getPlatform('darwin'), true)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/export_templates', '4.0.stable.mono')
)
})
test('3.5.1', () => {
expect(getExportTemplatePath('3.5.1', getPlatform('linux'), true)).toEqual(
path.join(os.homedir(), '.local/share/godot/templates', '3.5.1.stable.mono')
)
expect(getExportTemplatePath('3.5.1', getPlatform('win32'), true)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/templates', '3.5.1.stable.mono')
)
expect(getExportTemplatePath('3.5.1', getPlatform('darwin'), true)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/templates', '3.5.1.stable.mono')
)
})
test('3.5.0', () => {
expect(getExportTemplatePath('3.5.0', getPlatform('linux'), true)).toEqual(
path.join(os.homedir(), '.local/share/godot/templates', '3.5.stable.mono')
)
expect(getExportTemplatePath('3.5.0', getPlatform('win32'), true)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/templates', '3.5.stable.mono')
)
expect(getExportTemplatePath('3.5.0', getPlatform('darwin'), true)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/templates', '3.5.stable.mono')
)
})
})
describe('useDotnet = false', () => {
test('4.0.0-beta1', () => {
expect(getExportTemplatePath('4.0.0-beta1', getPlatform('linux'), false)).toEqual(
path.join(os.homedir(), '.local/share/godot/export_templates', '4.0.beta1')
)
expect(getExportTemplatePath('4.0.0-beta1', getPlatform('win32'), false)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/export_templates', '4.0.beta1')
)
expect(getExportTemplatePath('4.0.0-beta1', getPlatform('darwin'), false)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/export_templates', '4.0.beta1')
)
})
test('4.0.0', () => {
expect(getExportTemplatePath('4.0.0', getPlatform('linux'), false)).toEqual(
path.join(os.homedir(), '.local/share/godot/export_templates', '4.0.stable')
)
expect(getExportTemplatePath('4.0.0', getPlatform('win32'), false)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/export_templates', '4.0.stable')
)
expect(getExportTemplatePath('4.0.0', getPlatform('darwin'), false)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/export_templates', '4.0.stable')
)
})
test('3.5.1', () => {
expect(getExportTemplatePath('3.5.1', getPlatform('linux'), false)).toEqual(
path.join(os.homedir(), '.local/share/godot/templates', '3.5.1.stable')
)
expect(getExportTemplatePath('3.5.1', getPlatform('win32'), false)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/templates', '3.5.1.stable')
)
expect(getExportTemplatePath('3.5.1', getPlatform('darwin'), false)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/templates', '3.5.1.stable')
)
})
test('3.5.0', () => {
expect(getExportTemplatePath('3.5.0', getPlatform('linux'), false)).toEqual(
path.join(os.homedir(), '.local/share/godot/templates', '3.5.stable')
)
expect(getExportTemplatePath('3.5.0', getPlatform('win32'), false)).toEqual(
path.join(os.homedir(), 'AppData/Roaming/Godot/templates', '3.5.stable')
)
expect(getExportTemplatePath('3.5.0', getPlatform('darwin'), false)).toEqual(
path.join(os.homedir(), '/Library/Application Support/Godot/templates', '3.5.stable')
)
})
}) })
}) })

94
dist/index.js generated vendored
View File

@ -66,10 +66,13 @@ function run(platform = undefined) {
const downloadsDir = path_1.default.join(userDir, downloadsRelativePath); const downloadsDir = path_1.default.join(userDir, downloadsRelativePath);
const installationDir = path_1.default.join(userDir, pathRelative); const installationDir = path_1.default.join(userDir, pathRelative);
const versionName = (0, utils_1.getGodotFilenameFromVersionString)(version, platform, useDotnet); const versionName = (0, utils_1.getGodotFilenameFromVersionString)(version, platform, useDotnet);
const godotUrl = (0, utils_1.getGodotUrl)(version, platform, useDotnet); const godotUrl = (0, utils_1.getGodotUrl)(version, platform, useDotnet, false);
const godotDownloadPath = path_1.default.join(downloadsDir, `${versionName}.zip`); const godotDownloadPath = path_1.default.join(downloadsDir, `${versionName}.zip`);
const godotInstallationPath = platform.getUnzippedPath(installationDir, versionName, useDotnet); const godotInstallationPath = platform.getUnzippedPath(installationDir, versionName, useDotnet);
const binDir = path_1.default.join(userDir, binRelativePath); const binDir = path_1.default.join(userDir, binRelativePath);
const exportTemplateUrl = (0, utils_1.getGodotUrl)(version, platform, useDotnet, true);
const exportTemplatePath = (0, utils_1.getExportTemplatePath)(version, platform, useDotnet);
const exportTemplateDownloadPath = path_1.default.join(downloadsDir, 'export_templates.zip');
// Log values // Log values
core.startGroup('🤖 Godot Action Inputs'); core.startGroup('🤖 Godot Action Inputs');
core.info(`🤖 Godot version: ${version}`); core.info(`🤖 Godot version: ${version}`);
@ -81,6 +84,9 @@ function run(platform = undefined) {
core.info(`📥 Godot download path: ${godotDownloadPath}`); core.info(`📥 Godot download path: ${godotDownloadPath}`);
core.info(`📦 Godot installation directory: ${installationDir}`); core.info(`📦 Godot installation directory: ${installationDir}`);
core.info(`🤖 Godot installation path: ${godotInstallationPath}`); core.info(`🤖 Godot installation path: ${godotInstallationPath}`);
core.info(`🤖 Export Template url: ${exportTemplateUrl}`);
core.info(`📥 Export Template download path: ${exportTemplateDownloadPath}`);
core.info(`🤖 Export Template Path: ${exportTemplatePath}`);
core.info(`📂 Bin directory: ${binDir}`); core.info(`📂 Bin directory: ${binDir}`);
core.info(`🤖 GodotSharp release: ${godotSharpRelease}`); core.info(`🤖 GodotSharp release: ${godotSharpRelease}`);
core.endGroup(); core.endGroup();
@ -94,7 +100,7 @@ function run(platform = undefined) {
core.endGroup(); core.endGroup();
// See if Godot is already installed. // See if Godot is already installed.
core.startGroup(`🤔 Checking if Godot is already in cache...`); core.startGroup(`🤔 Checking if Godot is already in cache...`);
const cached = yield cache.restoreCache([godotInstallationPath], godotUrl); const cached = yield cache.restoreCache([godotInstallationPath, exportTemplatePath], godotUrl);
let executables; let executables;
if (!cached) { if (!cached) {
// Download Godot // Download Godot
@ -104,19 +110,34 @@ function run(platform = undefined) {
const godotDownloadedPath = yield toolsCache.downloadTool(godotUrl, godotDownloadPath); const godotDownloadedPath = yield toolsCache.downloadTool(godotUrl, godotDownloadPath);
core.info(`✅ Godot downloaded to ${godotDownloadedPath}`); core.info(`✅ Godot downloaded to ${godotDownloadedPath}`);
core.endGroup(); core.endGroup();
core.startGroup(`📥 Downloading Export Templates to ${exportTemplateDownloadPath}...`);
const templateDownloadedPath = yield toolsCache.downloadTool(exportTemplateUrl, exportTemplateDownloadPath);
core.info(`✅ Export Templates downloaded to ${templateDownloadedPath}`);
core.endGroup();
// Extract Godot // Extract Godot
core.startGroup(`📦 Extracting Godot to ${installationDir}...`); core.startGroup(`📦 Extracting Godot to ${installationDir}...`);
const godotExtractedPath = yield toolsCache.extractZip(godotDownloadedPath, installationDir); const godotExtractedPath = yield toolsCache.extractZip(godotDownloadedPath, installationDir);
core.info(`✅ Godot extracted to ${godotExtractedPath}`); core.info(`✅ Godot extracted to ${godotExtractedPath}`);
core.endGroup(); core.endGroup();
// Show extracted files recursively and list executables. // Show extracted Godot files recursively and list executables.
core.startGroup(`📄 Showing extracted files recursively...`); core.startGroup(`📄 Showing extracted files recursively...`);
executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, ''); executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, '');
core.info(`✅ Files shown`); core.info(`✅ Files shown`);
core.endGroup(); core.endGroup();
core.startGroup(`📦 Extracting Export Templates to ${exportTemplatePath}...`);
const exportTemplateExtractedPath = yield toolsCache.extractZip(templateDownloadedPath, path_1.default.dirname(exportTemplatePath));
core.info(`✅ Export Templates extracted to ${exportTemplateExtractedPath}`);
fs.renameSync(path_1.default.join(exportTemplateExtractedPath, 'templates'), exportTemplatePath);
core.info(`${path_1.default.join(path_1.default.dirname(exportTemplateExtractedPath), 'templates')} moved to ${exportTemplatePath}`);
core.endGroup();
// Show extracted Export Template files recursively
core.startGroup(`📄 Showing extracted files recursively...`);
yield (0, utils_1.findExecutablesRecursively)(platform, exportTemplatePath, '');
core.info(`✅ Files shown`);
core.endGroup();
// Save extracted Godot contents to cache // Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`); core.startGroup(`💾 Saving extracted Godot download to cache...`);
yield cache.saveCache([godotInstallationPath], godotUrl); yield cache.saveCache([godotInstallationPath, exportTemplatePath], godotUrl);
core.info(`✅ Godot saved to cache`); core.info(`✅ Godot saved to cache`);
core.endGroup(); core.endGroup();
} }
@ -125,6 +146,7 @@ function run(platform = undefined) {
core.endGroup(); core.endGroup();
core.startGroup(`📄 Showing cached files recursively...`); core.startGroup(`📄 Showing cached files recursively...`);
executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, ''); executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, '');
yield (0, utils_1.findExecutablesRecursively)(platform, exportTemplatePath, '');
core.info(`✅ Files shown`); core.info(`✅ Files shown`);
core.endGroup(); core.endGroup();
} }
@ -233,11 +255,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.findExecutablesRecursively = exports.getPlatform = exports.getGodotFilenameFromVersionString = exports.getGodotFilename = exports.getGodotUrl = exports.parseVersion = exports.MacOS = exports.Windows = exports.Linux = void 0; exports.findExecutablesRecursively = exports.getPlatform = exports.getGodotFilenameFromVersionString = exports.getGodotFilenameBase = exports.getGodotFilename = exports.getExportTemplatePath = exports.getGodotUrl = exports.parseVersion = exports.MacOS = exports.Windows = exports.Linux = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const os_1 = __importDefault(__nccwpck_require__(2037));
class Linux { class Linux {
constructor() {
this.GODOT_EXPORT_TEMPLATE_BASE_PATH = path_1.default.join(os_1.default.homedir(), '.local/share/godot');
}
godotFilenameSuffix(useDotnet) { godotFilenameSuffix(useDotnet) {
if (useDotnet) { if (useDotnet) {
return '_mono_linux_x86_64'; return '_mono_linux_x86_64';
@ -253,6 +279,9 @@ class Linux {
} }
exports.Linux = Linux; exports.Linux = Linux;
class Windows { class Windows {
constructor() {
this.GODOT_EXPORT_TEMPLATE_BASE_PATH = path_1.default.join(os_1.default.homedir(), '\\AppData\\Roaming\\Godot');
}
godotFilenameSuffix(useDotnet) { godotFilenameSuffix(useDotnet) {
if (useDotnet) { if (useDotnet) {
return '_mono_win64'; return '_mono_win64';
@ -268,6 +297,9 @@ class Windows {
} }
exports.Windows = Windows; exports.Windows = Windows;
class MacOS { class MacOS {
constructor() {
this.GODOT_EXPORT_TEMPLATE_BASE_PATH = path_1.default.join(os_1.default.homedir(), '/Library/Application Support/Godot/');
}
godotFilenameSuffix(useDotnet) { godotFilenameSuffix(useDotnet) {
return `${useDotnet ? '_mono' : ''}_macos.universal`; return `${useDotnet ? '_mono' : ''}_macos.universal`;
} }
@ -305,15 +337,15 @@ exports.parseVersion = parseVersion;
* @param versionString Version string. * @param versionString Version string.
* @param platform Current platform instance. * @param platform Current platform instance.
* @param useDotnet True to use the .NET-enabled version of Godot. * @param useDotnet True to use the .NET-enabled version of Godot.
* @param isTemplate True to return the url for the template
* @returns Godot binary download url. * @returns Godot binary download url.
*/ */
function getGodotUrl(versionString, platform, useDotnet) { function getGodotUrl(versionString, platform, useDotnet, isTemplate) {
const version = parseVersion(versionString); const version = parseVersion(versionString);
const major = version.major; const major = version.major;
const minor = version.minor; const minor = version.minor;
const patch = version.patch; const patch = version.patch;
const label = version.label.replace('.', ''); const label = version.label.replace('.', '');
const filename = getGodotFilename(version, platform, useDotnet);
let url = `${GODOT_URL_PREFIX + major}.${minor}`; let url = `${GODOT_URL_PREFIX + major}.${minor}`;
if (patch !== '' && patch !== '0') { if (patch !== '' && patch !== '0') {
url += `.${patch}`; url += `.${patch}`;
@ -322,16 +354,46 @@ function getGodotUrl(versionString, platform, useDotnet) {
if (label !== '') { if (label !== '') {
url += `${label}/`; url += `${label}/`;
} }
if (useDotnet) { if (useDotnet)
url += `mono/${filename}.zip`; url += `mono/`;
} if (!isTemplate)
else { return `${url}${getGodotFilename(version, platform, useDotnet)}.zip`;
url += `${filename}.zip`; return `${url}${getGodotFilenameBase(version)}${useDotnet ? '_mono' : ''}_export_templates.tpz`;
}
return url;
} }
exports.getGodotUrl = getGodotUrl; exports.getGodotUrl = getGodotUrl;
/**
* Returns the Godot export template local path
* @param versionString Version string.
* @param platform Current platform instance.
* @param useDotnet True to use the .NET-enabled version of Godot.
* @returns export template local path
*/
function getExportTemplatePath(versionString, platform, useDotnet) {
const version = parseVersion(versionString);
const major = version.major;
const minor = version.minor;
const patch = version.patch;
const label = version.label.replace('.', '');
let folderName = `${major}.${minor}`;
if (patch !== '' && patch !== '0') {
folderName += `.${patch}`;
}
if (label !== '') {
folderName += `.${label}`;
}
else {
folderName += '.stable';
}
if (useDotnet)
folderName += '.mono';
return path_1.default.join(platform.GODOT_EXPORT_TEMPLATE_BASE_PATH, version.major === '4' ? 'export_templates' : 'templates', folderName);
}
exports.getExportTemplatePath = getExportTemplatePath;
function getGodotFilename(version, platform, useDotnet) { function getGodotFilename(version, platform, useDotnet) {
return getGodotFilenameBase(version) + platform.godotFilenameSuffix(useDotnet);
}
exports.getGodotFilename = getGodotFilename;
function getGodotFilenameBase(version) {
const major = version.major; const major = version.major;
const minor = version.minor; const minor = version.minor;
const patch = version.patch; const patch = version.patch;
@ -349,9 +411,9 @@ function getGodotFilename(version, platform, useDotnet) {
else { else {
filename += '-stable'; filename += '-stable';
} }
return filename + platform.godotFilenameSuffix(useDotnet); return filename;
} }
exports.getGodotFilename = getGodotFilename; exports.getGodotFilenameBase = getGodotFilenameBase;
function getGodotFilenameFromVersionString(versionString, platform, useDotnet) { function getGodotFilenameFromVersionString(versionString, platform, useDotnet) {
return getGodotFilename(parseVersion(versionString), platform, useDotnet); return getGodotFilename(parseVersion(versionString), platform, useDotnet);
} }

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@ import path from 'path'
import { import {
findExecutablesRecursively, findExecutablesRecursively,
getExportTemplatePath,
getGodotFilenameFromVersionString, getGodotFilenameFromVersionString,
getGodotUrl, getGodotUrl,
getPlatform, getPlatform,
@ -35,7 +36,7 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
platform, platform,
useDotnet useDotnet
) )
const godotUrl = getGodotUrl(version, platform, useDotnet) const godotUrl = getGodotUrl(version, platform, useDotnet, false)
const godotDownloadPath = path.join(downloadsDir, `${versionName}.zip`) const godotDownloadPath = path.join(downloadsDir, `${versionName}.zip`)
const godotInstallationPath = platform.getUnzippedPath( const godotInstallationPath = platform.getUnzippedPath(
installationDir, installationDir,
@ -44,6 +45,13 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
) )
const binDir = path.join(userDir, binRelativePath) const binDir = path.join(userDir, binRelativePath)
const exportTemplateUrl = getGodotUrl(version, platform, useDotnet, true)
const exportTemplatePath = getExportTemplatePath(version, platform, useDotnet)
const exportTemplateDownloadPath = path.join(
downloadsDir,
'export_templates.zip'
)
// Log values // Log values
core.startGroup('🤖 Godot Action Inputs') core.startGroup('🤖 Godot Action Inputs')
core.info(`🤖 Godot version: ${version}`) core.info(`🤖 Godot version: ${version}`)
@ -55,6 +63,9 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
core.info(`📥 Godot download path: ${godotDownloadPath}`) core.info(`📥 Godot download path: ${godotDownloadPath}`)
core.info(`📦 Godot installation directory: ${installationDir}`) core.info(`📦 Godot installation directory: ${installationDir}`)
core.info(`🤖 Godot installation path: ${godotInstallationPath}`) core.info(`🤖 Godot installation path: ${godotInstallationPath}`)
core.info(`🤖 Export Template url: ${exportTemplateUrl}`)
core.info(`📥 Export Template download path: ${exportTemplateDownloadPath}`)
core.info(`🤖 Export Template Path: ${exportTemplatePath}`)
core.info(`📂 Bin directory: ${binDir}`) core.info(`📂 Bin directory: ${binDir}`)
core.info(`🤖 GodotSharp release: ${godotSharpRelease}`) core.info(`🤖 GodotSharp release: ${godotSharpRelease}`)
core.endGroup() core.endGroup()
@ -70,7 +81,10 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
// See if Godot is already installed. // See if Godot is already installed.
core.startGroup(`🤔 Checking if Godot is already in cache...`) core.startGroup(`🤔 Checking if Godot is already in cache...`)
const cached = await cache.restoreCache([godotInstallationPath], godotUrl) const cached = await cache.restoreCache(
[godotInstallationPath, exportTemplatePath],
godotUrl
)
let executables: string[] let executables: string[]
if (!cached) { if (!cached) {
@ -86,6 +100,16 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
core.info(`✅ Godot downloaded to ${godotDownloadedPath}`) core.info(`✅ Godot downloaded to ${godotDownloadedPath}`)
core.endGroup() core.endGroup()
core.startGroup(
`📥 Downloading Export Templates to ${exportTemplateDownloadPath}...`
)
const templateDownloadedPath = await toolsCache.downloadTool(
exportTemplateUrl,
exportTemplateDownloadPath
)
core.info(`✅ Export Templates downloaded to ${templateDownloadedPath}`)
core.endGroup()
// Extract Godot // Extract Godot
core.startGroup(`📦 Extracting Godot to ${installationDir}...`) core.startGroup(`📦 Extracting Godot to ${installationDir}...`)
const godotExtractedPath = await toolsCache.extractZip( const godotExtractedPath = await toolsCache.extractZip(
@ -95,7 +119,7 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
core.info(`✅ Godot extracted to ${godotExtractedPath}`) core.info(`✅ Godot extracted to ${godotExtractedPath}`)
core.endGroup() core.endGroup()
// Show extracted files recursively and list executables. // Show extracted Godot files recursively and list executables.
core.startGroup(`📄 Showing extracted files recursively...`) core.startGroup(`📄 Showing extracted files recursively...`)
executables = await findExecutablesRecursively( executables = await findExecutablesRecursively(
platform, platform,
@ -105,9 +129,40 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
core.info(`✅ Files shown`) core.info(`✅ Files shown`)
core.endGroup() core.endGroup()
core.startGroup(
`📦 Extracting Export Templates to ${exportTemplatePath}...`
)
const exportTemplateExtractedPath = await toolsCache.extractZip(
templateDownloadedPath,
path.dirname(exportTemplatePath)
)
core.info(
`✅ Export Templates extracted to ${exportTemplateExtractedPath}`
)
fs.renameSync(
path.join(exportTemplateExtractedPath, 'templates'),
exportTemplatePath
)
core.info(
`${path.join(
path.dirname(exportTemplateExtractedPath),
'templates'
)} moved to ${exportTemplatePath}`
)
core.endGroup()
// Show extracted Export Template files recursively
core.startGroup(`📄 Showing extracted files recursively...`)
await findExecutablesRecursively(platform, exportTemplatePath, '')
core.info(`✅ Files shown`)
core.endGroup()
// Save extracted Godot contents to cache // Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`) core.startGroup(`💾 Saving extracted Godot download to cache...`)
await cache.saveCache([godotInstallationPath], godotUrl) await cache.saveCache(
[godotInstallationPath, exportTemplatePath],
godotUrl
)
core.info(`✅ Godot saved to cache`) core.info(`✅ Godot saved to cache`)
core.endGroup() core.endGroup()
} else { } else {
@ -120,6 +175,7 @@ async function run(platform: Platform | undefined = undefined): Promise<void> {
installationDir, installationDir,
'' ''
) )
await findExecutablesRecursively(platform, exportTemplatePath, '')
core.info(`✅ Files shown`) core.info(`✅ Files shown`)
core.endGroup() core.endGroup()
} }

View File

@ -1,6 +1,7 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as fs from 'fs' import * as fs from 'fs'
import path from 'path' import path from 'path'
import os from 'os'
export interface Platform { export interface Platform {
/** Godot installation filename suffix. */ /** Godot installation filename suffix. */
@ -21,9 +22,16 @@ export interface Platform {
versionName: string, versionName: string,
useDotnet: boolean useDotnet: boolean
): string ): string
GODOT_EXPORT_TEMPLATE_BASE_PATH: string
} }
export class Linux implements Platform { export class Linux implements Platform {
GODOT_EXPORT_TEMPLATE_BASE_PATH = path.join(
os.homedir(),
'.local/share/godot'
)
godotFilenameSuffix(useDotnet: boolean): string { godotFilenameSuffix(useDotnet: boolean): string {
if (useDotnet) { if (useDotnet) {
return '_mono_linux_x86_64' return '_mono_linux_x86_64'
@ -43,6 +51,11 @@ export class Linux implements Platform {
} }
export class Windows implements Platform { export class Windows implements Platform {
GODOT_EXPORT_TEMPLATE_BASE_PATH = path.join(
os.homedir(),
'\\AppData\\Roaming\\Godot'
)
godotFilenameSuffix(useDotnet: boolean): string { godotFilenameSuffix(useDotnet: boolean): string {
if (useDotnet) { if (useDotnet) {
return '_mono_win64' return '_mono_win64'
@ -62,6 +75,11 @@ export class Windows implements Platform {
} }
export class MacOS implements Platform { export class MacOS implements Platform {
GODOT_EXPORT_TEMPLATE_BASE_PATH = path.join(
os.homedir(),
'/Library/Application Support/Godot/'
)
godotFilenameSuffix(useDotnet: boolean): string { godotFilenameSuffix(useDotnet: boolean): string {
return `${useDotnet ? '_mono' : ''}_macos.universal` return `${useDotnet ? '_mono' : ''}_macos.universal`
} }
@ -119,9 +137,48 @@ export function parseVersion(version: string): SemanticVersion {
* @param versionString Version string. * @param versionString Version string.
* @param platform Current platform instance. * @param platform Current platform instance.
* @param useDotnet True to use the .NET-enabled version of Godot. * @param useDotnet True to use the .NET-enabled version of Godot.
* @param isTemplate True to return the url for the template
* @returns Godot binary download url. * @returns Godot binary download url.
*/ */
export function getGodotUrl( export function getGodotUrl(
versionString: string,
platform: Platform,
useDotnet: boolean,
isTemplate: boolean
): string {
const version = parseVersion(versionString)
const major = version.major
const minor = version.minor
const patch = version.patch
const label = version.label.replace('.', '')
let url = `${GODOT_URL_PREFIX + major}.${minor}`
if (patch !== '' && patch !== '0') {
url += `.${patch}`
}
url += '/'
if (label !== '') {
url += `${label}/`
}
if (useDotnet) url += `mono/`
if (!isTemplate)
return `${url}${getGodotFilename(version, platform, useDotnet)}.zip`
return `${url}${getGodotFilenameBase(version)}${
useDotnet ? '_mono' : ''
}_export_templates.tpz`
}
/**
* Returns the Godot export template local path
* @param versionString Version string.
* @param platform Current platform instance.
* @param useDotnet True to use the .NET-enabled version of Godot.
* @returns export template local path
*/
export function getExportTemplatePath(
versionString: string, versionString: string,
platform: Platform, platform: Platform,
useDotnet: boolean useDotnet: boolean
@ -132,23 +189,22 @@ export function getGodotUrl(
const patch = version.patch const patch = version.patch
const label = version.label.replace('.', '') const label = version.label.replace('.', '')
const filename = getGodotFilename(version, platform, useDotnet) let folderName = `${major}.${minor}`
let url = `${GODOT_URL_PREFIX + major}.${minor}`
if (patch !== '' && patch !== '0') { if (patch !== '' && patch !== '0') {
url += `.${patch}` folderName += `.${patch}`
} }
url += '/'
if (label !== '') { if (label !== '') {
url += `${label}/` folderName += `.${label}`
}
if (useDotnet) {
url += `mono/${filename}.zip`
} else { } else {
url += `${filename}.zip` folderName += '.stable'
} }
if (useDotnet) folderName += '.mono'
return url return path.join(
platform.GODOT_EXPORT_TEMPLATE_BASE_PATH,
version.major === '4' ? 'export_templates' : 'templates',
folderName
)
} }
export function getGodotFilename( export function getGodotFilename(
@ -156,6 +212,10 @@ export function getGodotFilename(
platform: Platform, platform: Platform,
useDotnet: boolean useDotnet: boolean
): string { ): string {
return getGodotFilenameBase(version) + platform.godotFilenameSuffix(useDotnet)
}
export function getGodotFilenameBase(version: SemanticVersion): string {
const major = version.major const major = version.major
const minor = version.minor const minor = version.minor
const patch = version.patch const patch = version.patch
@ -175,7 +235,7 @@ export function getGodotFilename(
filename += '-stable' filename += '-stable'
} }
return filename + platform.godotFilenameSuffix(useDotnet) return filename
} }
export function getGodotFilenameFromVersionString( export function getGodotFilenameFromVersionString(