diff --git a/README.md b/README.md index 3af83f20..ac97b654 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ Since this action creates releases and uploads the zip file assets, you will nee - If release notes should be automatically generated based on commit history. The generated notes will be added as the body of the release. - **Note**: This input is only used when `create_release` is `true`. - **Note**: When using the GitHub checkout action, ensure you are fetching the entire project history by including `fetch-depth: 0`. See the example workflow configuration for more context. +- `use_preset_export_path` default `false` + - If set to true, exports will be moved to directory defined in `export_presets.cfg` relative to the root of the Git repository. Prioritized over `relative_export_path`. - `relative_export_path` default `''` - If provided, exports will be moved to this directory relative to the root of the Git repository. - `update_windows_icons` default `false` diff --git a/action.yml b/action.yml index 589820ff..7f09d355 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,10 @@ inputs: description: If release notes should be automatically generated based on commit history. default: false required: false + use_preset_export_path: + description: If set to true, exports will be moved to directory defined in "export_presets.cfg" relative to the root of the Git repository. Prioritized over "relative_export_path". + default: false + required: false relative_export_path: description: If provided, exports will be moved to this directory relative to the root of the Git repository. default: '' diff --git a/dist/index.js b/dist/index.js index 1250a9af..3c804f9a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11921,6 +11921,7 @@ const RELATIVE_EXPORT_PATH = Object(core.getInput)('relative_export_path'); const RELATIVE_PROJECT_PATH = Object(core.getInput)('relative_project_path'); const SHOULD_CREATE_RELEASE = Object(core.getInput)('create_release') === 'true'; const UPDATE_WINDOWS_ICONS = Object(core.getInput)('update_windows_icons') === 'true'; +const USE_PRESET_EXPORT_PATH = Object(core.getInput)('use_preset_export_path') === 'true'; const GODOT_WORKING_PATH = external_path_default().resolve(external_path_default().join(Object(external_os_.homedir)(), '/.local/share/godot')); const GODOT_CONFIG_PATH = external_path_default().resolve(external_path_default().join(Object(external_os_.homedir)(), '/.config/godot')); @@ -12247,11 +12248,11 @@ function zipBuildResult(buildResult) { } function moveBuildsToExportDirectory(buildResults, moveArchived) { return file_awaiter(this, void 0, void 0, function* () { - const fullExportPath = external_path_default().resolve(RELATIVE_EXPORT_PATH); - Object(core.startGroup)(`Moving exports to ${fullExportPath}`); - yield Object(io.mkdirP)(fullExportPath); + Object(core.startGroup)(`Moving exports`); const promises = []; for (const buildResult of buildResults) { + const fullExportPath = external_path_default().resolve(USE_PRESET_EXPORT_PATH ? external_path_default().dirname(buildResult.preset.export_path) : RELATIVE_EXPORT_PATH); + yield Object(io.mkdirP)(fullExportPath); let promise; if (moveArchived) { if (!buildResult.archivePath) { @@ -12455,7 +12456,7 @@ function main() { if (ARCHIVE_EXPORT_OUTPUT) { yield zipBuildResults(buildResults); } - if (RELATIVE_EXPORT_PATH) { + if (RELATIVE_EXPORT_PATH || USE_PRESET_EXPORT_PATH) { yield moveBuildsToExportDirectory(buildResults, ARCHIVE_EXPORT_OUTPUT); } if (SHOULD_CREATE_RELEASE) { diff --git a/src/constants.ts b/src/constants.ts index 4f6f78a5..db5346a7 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -12,6 +12,7 @@ const RELATIVE_EXPORT_PATH = core.getInput('relative_export_path'); const RELATIVE_PROJECT_PATH = core.getInput('relative_project_path'); const SHOULD_CREATE_RELEASE = core.getInput('create_release') === 'true'; const UPDATE_WINDOWS_ICONS = core.getInput('update_windows_icons') === 'true'; +const USE_PRESET_EXPORT_PATH = core.getInput('use_preset_export_path') === 'true'; const GODOT_WORKING_PATH = path.resolve(path.join(os.homedir(), '/.local/share/godot')); const GODOT_CONFIG_PATH = path.resolve(path.join(os.homedir(), '/.config/godot')); @@ -29,4 +30,5 @@ export { RELATIVE_PROJECT_PATH, SHOULD_CREATE_RELEASE, UPDATE_WINDOWS_ICONS, + USE_PRESET_EXPORT_PATH, }; diff --git a/src/file.ts b/src/file.ts index 98a75453..d669172d 100644 --- a/src/file.ts +++ b/src/file.ts @@ -3,7 +3,7 @@ import path from 'path'; import * as io from '@actions/io'; import { exec } from '@actions/exec'; import * as fs from 'fs'; -import { GODOT_WORKING_PATH, RELATIVE_EXPORT_PATH } from './constants'; +import { GODOT_WORKING_PATH, RELATIVE_EXPORT_PATH, USE_PRESET_EXPORT_PATH } from './constants'; import * as core from '@actions/core'; async function zipBuildResults(buildResults: BuildResult[]): Promise { @@ -35,13 +35,15 @@ async function zipBuildResult(buildResult: BuildResult): Promise { } async function moveBuildsToExportDirectory(buildResults: BuildResult[], moveArchived?: boolean): Promise { - const fullExportPath = path.resolve(RELATIVE_EXPORT_PATH); - core.startGroup(`Moving exports to ${fullExportPath}`); - - await io.mkdirP(fullExportPath); - + core.startGroup(`Moving exports`); const promises: Promise[] = []; for (const buildResult of buildResults) { + const fullExportPath = path.resolve( + USE_PRESET_EXPORT_PATH ? path.dirname(buildResult.preset.export_path) : RELATIVE_EXPORT_PATH, + ); + + await io.mkdirP(fullExportPath); + let promise: Promise; if (moveArchived) { if (!buildResult.archivePath) { diff --git a/src/main.ts b/src/main.ts index 7dfc45d8..f7844407 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,12 @@ import * as core from '@actions/core'; import { exportBuilds } from './godot'; import { createRelease } from './release'; -import { SHOULD_CREATE_RELEASE, ARCHIVE_EXPORT_OUTPUT, RELATIVE_EXPORT_PATH } from './constants'; +import { + SHOULD_CREATE_RELEASE, + ARCHIVE_EXPORT_OUTPUT, + RELATIVE_EXPORT_PATH, + USE_PRESET_EXPORT_PATH, +} from './constants'; import { zipBuildResults, moveBuildsToExportDirectory } from './file'; async function main(): Promise { @@ -15,7 +20,7 @@ async function main(): Promise { await zipBuildResults(buildResults); } - if (RELATIVE_EXPORT_PATH) { + if (RELATIVE_EXPORT_PATH || USE_PRESET_EXPORT_PATH) { await moveBuildsToExportDirectory(buildResults, ARCHIVE_EXPORT_OUTPUT); }