KoBeWi / Godot-Auto-Export-Version

Plugin for Godot that automatically updates your version every time you export the project.
https://godotengine.org/asset-library/asset/1430
MIT License
50 stars 4 forks source link

Tools -> AutoExport: Print and Update Current Version always resets the version to "1" #10

Open dragonforge-dev opened 3 months ago

dragonforge-dev commented 3 months ago

My version is 1.0.2.0 in project_settings/application/config/version When I run the AutoExport, it changes me version to 1. If I export it to a file, it does the same thing. I've tried version = get_export_preset_version() and version = get_export_preset_android_version_code() and both do the same thing. (Note I removed the += in both.)

Steps to Reproduce:

  1. Install the plugin.
  2. Set your project_settings/application/config/version value to 1.0.2.0
  3. Activate it.
  4. Edit auto_export_version_config_file.d to contain the line: version = get_export_preset_version()
  5. Run Tools -> AutoExport: Print and Update Current Version

RESULT: The version is set to 1. EXPECTED: The version would be set to 1.0.2.0

KoBeWi commented 3 months ago

Set your project_settings/application/config/version value to 1.0.2.0

But the plugin is supposed to set this setting. The export preset provider uses version from export dialog presets and assigns it to project setting.

dragonforge-dev commented 3 months ago

Ah, well I guess I should have mentioned then that all my exports pull the value from the Project setting. Perhaps this just won't work for me.

KoBeWi commented 3 months ago

AFAIK the project setting is used automatically if you don't fill your export preset. The export profile provider was added before the setting was added to the engine, nowadays it might be obsolete. Auto Version addon is for filling the version automatically, so you don't have to remember to change it for each release. If you are setting the version manually then you don't need it.

dragonforge-dev commented 3 months ago

Fair enough. I just ended up solving my problem this way:

func _ready():  
    var project_version = ProjectSettings.get_setting("application/config/version")
    var version_file_path = "res://version.txt"
    var saved_version = FileAccess.open(version_file_path, FileAccess.READ).get_as_text()

    if project_version == "":
        project_version = "v%s" % saved_version
    elif project_version != saved_version:
        FileAccess.open(version_file_path, FileAccess.WRITE).store_string(project_version)

    $VersionLabel.text = project_version
KoBeWi commented 3 months ago

What is version.txt for? Is this game code or editor code? Not sure what is your problem.

dragonforge-dev commented 3 months ago

My problem is ProjectSettings.get_setting("application/config/version") doesn't bring back anything once I export the project. I just wanted to add a version label and I only wanted to update the version in one place.

KoBeWi commented 3 months ago

ProjectSettings.get_setting("application/config/version") doesn't bring back anything once I export the project

Well that's weird. I can't reproduce it in my project. Try disabling the plugin and exporting again. If auto version is enabled and misconfigured, it might be messing with your setting.

dragonforge-dev commented 3 months ago

I disabled and removed and re-installed the plugin multiple times. No joy. I appreciate the responses. I'll play with it again in a clean project.