Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/Config/Version` in Godot. Useful for embedding version info into the exported game. | `string` | `''` | No |

### Action Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
49 changes: 49 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -73,4 +74,5 @@ export {
USE_GODOT_3,
USE_PRESET_EXPORT_PATH,
WINE_PATH,
PROJECT_VERSION,
};
51 changes: 51 additions & 0 deletions src/godot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
GODOT_EXPORT_TEMPLATES_PATH,
CACHE_ACTIVE,
GODOT_PROJECT_PATH,
PROJECT_VERSION,
} from './constants';

const GODOT_EXECUTABLE = 'godot_executable';
Expand Down Expand Up @@ -51,6 +52,12 @@ async function exportBuilds(): Promise<BuildResult[]> {
await addEditorSettings();
core.endGroup();

if (PROJECT_VERSION) {
core.startGroup('🔧 Adding Project Settings');
setProjectVersion();
core.endGroup();
}

if (WINE_PATH) {
configureWindowsExport();
}
Expand Down Expand Up @@ -405,6 +412,50 @@ async function addEditorSettings(): Promise<void> {
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');
Expand Down