From 1a61f6665d55189ab9d2f20442674c5722621f8a Mon Sep 17 00:00:00 2001 From: Joshua Weiss <44821795+JoshuaWeissTBS@users.noreply.github.com> Date: Sun, 31 Aug 2025 13:15:39 -0700 Subject: [PATCH 1/2] Project version option (#1) * add project version support to export process * updated build example godot urls * add project version to yml * Added project_version to action.yml * Add project version logging and grouping to export process * built project --- .github/workflows/build-example.yml | 5 +-- README.md | 2 +- action.yml | 4 +++ dist/index.js | 49 +++++++++++++++++++++++++++ src/constants.ts | 2 ++ src/godot.ts | 51 +++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-example.yml b/.github/workflows/build-example.yml index 7914b8c0..8f60e643 100644 --- a/.github/workflows/build-example.yml +++ b/.github/workflows/build-example.yml @@ -23,12 +23,13 @@ jobs: id: export uses: firebelley/godot-export@v7.0.0 with: - godot_executable_download_url: https://downloads.tuxfamily.org/godotengine/4.0/Godot_v4.0-stable_linux.x86_64.zip - godot_export_templates_download_url: https://downloads.tuxfamily.org/godotengine/4.0/Godot_v4.0-stable_export_templates.tpz + godot_executable_download_url: https://github.com/godotengine/godot-builds/releases/download/4.4-stable/Godot_v4.4-stable_linux.x86_64.zip + godot_export_templates_download_url: https://github.com/godotengine/godot-builds/releases/download/4.4-stable/Godot_v4.4-stable_export_templates.tpz relative_project_path: ./examples/project-godot-4 # build the standard project relative_export_path: ./my/build/destination # move export output to this directory relative to git root archive_output: true wine_path: ${{ steps.wine_install.outputs.WINE_PATH }} + project_version: ${{ github.ref_name }} - name: create release uses: ncipollo/release-action@v1.18.0 with: diff --git a/README.md b/README.md index 1f5ec3f1..b2707973 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Define at least 1 export preset by going to `Project -> Export` in the Godot edi | `use_godot_3` | Build using Godot 3 executable. **NOTE**: `godot_executable_download_url` and `godot_export_templates_download_url` still need to be configured to download the correct version. | `boolean` | `false` | No | | `export_as_pack` | Export project files as a .pck file | `boolean` | `false` | No | | `presets_to_export` | A comma-separated list of export presets to export. If not specified, all presets will be exported. EX: `Windows, Mac OSX, android` | `string` | `''` | No | - +| `project_version` | The version of your project. Sets the project settings `Application/Version` in Godot. | `string` | `''` | No | ### Action Outputs diff --git a/action.yml b/action.yml index 8b408b69..854525c1 100644 --- a/action.yml +++ b/action.yml @@ -61,6 +61,10 @@ inputs: description: A comma-separated list of export presets to export. If not specified, all presets will be exported. default: '' required: false + project_version: + description: The version of your project. Sets the project settings `Application/Version` in Godot. + default: '' + required: false outputs: diff --git a/dist/index.js b/dist/index.js index 0af30f0f..5efa2aeb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -76948,6 +76948,7 @@ const GODOT_VERBOSE = core.getBooleanInput('verbose'); const ARCHIVE_ROOT_FOLDER = core.getBooleanInput('archive_root_folder'); const USE_GODOT_3 = core.getBooleanInput('use_godot_3'); const EXPORT_PACK_ONLY = core.getBooleanInput('export_as_pack'); +const PROJECT_VERSION = core.getInput('project_version'); // Parse export targets const exportPresetsStr = core.getInput('presets_to_export').trim(); let exportPresets = null; @@ -77002,6 +77003,11 @@ async function exportBuilds() { core.startGroup('🔍 Adding Editor Settings'); await addEditorSettings(); core.endGroup(); + if (PROJECT_VERSION) { + core.startGroup('🔧 Adding Project Settings'); + setProjectVersion(); + core.endGroup(); + } if (WINE_PATH) { configureWindowsExport(); } @@ -77299,6 +77305,49 @@ async function addEditorSettings() { await io.cp(editorSettingsDist, editorSettingsPath, { force: false }); core.info(`Wrote editor settings to ${editorSettingsPath}`); } +function setProjectVersion() { + // Always update or insert config/version under [application] section + const projectFilePath = GODOT_PROJECT_FILE_PATH; + const content = external_fs_.readFileSync(projectFilePath, { encoding: 'utf8' }); + const lines = content.split(/\r?\n/); + let inApplication = false; + let versionSet = false; + const output = []; + for (const line of lines) { + if (line.startsWith('[application]')) { + inApplication = true; + output.push(line); + continue; + } + if (inApplication && line.startsWith('[')) { + // Leaving [application] section, insert version if not set + if (!versionSet && PROJECT_VERSION) { + output.push(`config/version = "${PROJECT_VERSION}"`); + versionSet = true; + } + inApplication = false; + } + if (inApplication && line.trim().startsWith('config/version')) { + if (PROJECT_VERSION) { + output.push(`config/version = "${PROJECT_VERSION}"`); + } + versionSet = true; + continue; + } + output.push(line); + } + // If [application] is at the end and version not set + if (inApplication && !versionSet && PROJECT_VERSION) { + output.push(`config/version = "${PROJECT_VERSION}"`); + } + external_fs_.writeFileSync(projectFilePath, output.join('\n'), { encoding: 'utf8' }); + if (PROJECT_VERSION) { + core.info(`Set project version to ${PROJECT_VERSION}`); + } + else { + core.warning(`No project version set.`); + } +} function configureWindowsExport() { core.startGroup('📝 Appending Wine editor settings'); const rceditPath = external_path_.join(__dirname, 'rcedit-x64.exe'); diff --git a/src/constants.ts b/src/constants.ts index a37475bc..6df62625 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -16,6 +16,7 @@ const GODOT_VERBOSE = core.getBooleanInput('verbose'); const ARCHIVE_ROOT_FOLDER = core.getBooleanInput('archive_root_folder'); const USE_GODOT_3 = core.getBooleanInput('use_godot_3'); const EXPORT_PACK_ONLY = core.getBooleanInput('export_as_pack'); +const PROJECT_VERSION = core.getInput('project_version'); // Parse export targets const exportPresetsStr = core.getInput('presets_to_export').trim(); @@ -73,4 +74,5 @@ export { USE_GODOT_3, USE_PRESET_EXPORT_PATH, WINE_PATH, + PROJECT_VERSION, }; diff --git a/src/godot.ts b/src/godot.ts index f40c83c1..4424f0ae 100644 --- a/src/godot.ts +++ b/src/godot.ts @@ -24,6 +24,7 @@ import { GODOT_EXPORT_TEMPLATES_PATH, CACHE_ACTIVE, GODOT_PROJECT_PATH, + PROJECT_VERSION, } from './constants'; const GODOT_EXECUTABLE = 'godot_executable'; @@ -51,6 +52,12 @@ async function exportBuilds(): Promise { await addEditorSettings(); core.endGroup(); + if (PROJECT_VERSION) { + core.startGroup('🔧 Adding Project Settings'); + setProjectVersion(); + core.endGroup(); + } + if (WINE_PATH) { configureWindowsExport(); } @@ -405,6 +412,50 @@ async function addEditorSettings(): Promise { core.info(`Wrote editor settings to ${editorSettingsPath}`); } +function setProjectVersion(): void { + // Always update or insert config/version under [application] section + const projectFilePath = GODOT_PROJECT_FILE_PATH; + const content = fs.readFileSync(projectFilePath, { encoding: 'utf8' }); + const lines = content.split(/\r?\n/); + let inApplication = false; + let versionSet = false; + const output: string[] = []; + + for (const line of lines) { + if (line.startsWith('[application]')) { + inApplication = true; + output.push(line); + continue; + } + if (inApplication && line.startsWith('[')) { + // Leaving [application] section, insert version if not set + if (!versionSet && PROJECT_VERSION) { + output.push(`config/version = "${PROJECT_VERSION}"`); + versionSet = true; + } + inApplication = false; + } + if (inApplication && line.trim().startsWith('config/version')) { + if (PROJECT_VERSION) { + output.push(`config/version = "${PROJECT_VERSION}"`); + } + versionSet = true; + continue; + } + output.push(line); + } + // If [application] is at the end and version not set + if (inApplication && !versionSet && PROJECT_VERSION) { + output.push(`config/version = "${PROJECT_VERSION}"`); + } + fs.writeFileSync(projectFilePath, output.join('\n'), { encoding: 'utf8' }); + if (PROJECT_VERSION) { + core.info(`Set project version to ${PROJECT_VERSION}`); + } else { + core.warning(`No project version set.`); + } +} + function configureWindowsExport(): void { core.startGroup('📝 Appending Wine editor settings'); const rceditPath = path.join(__dirname, 'rcedit-x64.exe'); From aa3fb908dfa50913961b6a1960b631ffbf344caa Mon Sep 17 00:00:00 2001 From: Joshua Weiss <44821795+JoshuaWeissTBS@users.noreply.github.com> Date: Sun, 31 Aug 2025 13:33:43 -0700 Subject: [PATCH 2/2] Project version option (#2) * add project version support to export process * updated build example godot urls * add project version to yml * Added project_version to action.yml * Add project version logging and grouping to export process * built project * updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2707973..8b7a6431 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Define at least 1 export preset by going to `Project -> Export` in the Godot edi | `use_godot_3` | Build using Godot 3 executable. **NOTE**: `godot_executable_download_url` and `godot_export_templates_download_url` still need to be configured to download the correct version. | `boolean` | `false` | No | | `export_as_pack` | Export project files as a .pck file | `boolean` | `false` | No | | `presets_to_export` | A comma-separated list of export presets to export. If not specified, all presets will be exported. EX: `Windows, Mac OSX, android` | `string` | `''` | No | -| `project_version` | The version of your project. Sets the project settings `Application/Version` in Godot. | `string` | `''` | No | +| `project_version` | The version of your project. Sets the project settings `Application/Config/Version` in Godot. Useful for embedding version info into the exported game. | `string` | `''` | No | ### Action Outputs