├── icon.png ├── .gitignore ├── addons └── GodotVersion │ ├── plugin.cfg │ └── plugin.gd ├── LICENSE └── README.md /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gregorein/GodotVersion/HEAD/icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Godot-specific ignores 3 | .import/ 4 | export.cfg 5 | export_presets.cfg 6 | 7 | # Mono-specific ignores 8 | .mono/ 9 | data_*/ 10 | 11 | # Releases 12 | releases/ -------------------------------------------------------------------------------- /addons/GodotVersion/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name="GodotVersion" 4 | description="This plugin updates project with latest value from GitVersion" 5 | author="Gregorein" 6 | version="0.3.0" 7 | script="GodotVersion.gd" 8 | -------------------------------------------------------------------------------- /addons/GodotVersion/plugin.gd: -------------------------------------------------------------------------------- 1 | @tool 2 | extends EditorPlugin 3 | 4 | var path = "res://GitVersion.json" 5 | var file 6 | 7 | func _enter_tree(): 8 | if FileAccess.file_exists(path): 9 | file = FileAccess.open(path, FileAccess.READ) 10 | 11 | updateVersion() 12 | 13 | func _build(): 14 | updateVersion() 15 | 16 | return true 17 | 18 | func updateVersion(): 19 | var version = JSON.parse_string(file.get_as_text())["SemVer"] 20 | 21 | ProjectSettings.set_setting("version", version) 22 | ProjectSettings.save() 23 | 24 | print("version: ", version) 25 | 26 | func _exit_tree(): 27 | file = null 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Greg Bak 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | # GodotVersion 4 | *From `git log` to `SemVer` to `Godot` in no time. 5 | An automation plugin working with GitVersion* 6 | 7 | ## About 8 | The GodotVersion plugin makes it easier to manage version updates for your Godot projects. It works with GitVersion and a git pre-commit hook to update the project version automatically when a build is started - both for debug and exports. 9 | 10 | This plugin can be used for both game and non-game projects. 11 | 12 | ## Getting started 13 | ### 1. Installing Git 14 | To get started with the GodotVersion plugin, you'll need to have Git installed on your machine. Use package manager like `Homebrew`, `Chocolatey` or go to the Git website and install the latest version. 15 | 16 | > **Warning:** 17 | > Make sure you have version 2.9 or later of Git installed. 18 | >You can check your Git version by running git --version in a terminal. 19 | 20 | ### 2. Installing GitVersion 21 | Once you have Git installed, you'll need to install GitVersion. There are several ways to install GitVersion, including using the `Homebrew` or `Chocolatey`. You can find detailed installation instructions on the [GitVersion website](https://gitversion.net/docs/usage/cli/installation). 22 | 23 | > **Note:** 24 | >To learn more about GitFlow, see the [GitFlow documentation](https://docs.github.com/en/get-started/quickstart/github-flow). 25 | >You can customize GitVersion by editing the gitversion.yml file. See the [GitVersion documentation](https://gitversion.net/docs/usage/cli/) for details. 26 | 27 | ### 3. Installing `pre-commit` git hook 28 | 29 | After installing GitVersion, you'll need to set up a custom `pre-commit` git hook. 30 | To do this, create a file called `pre-commit` in the `.git/hooks` directory of your project repository. 31 | 32 | You can use the following script as a starting point: 33 | 34 | ```bash 35 | #!/bin/sh 36 | 37 | # Check that GitVersion is installed 38 | which gitversion || exit 0 39 | 40 | # Update the version number and commit it 41 | gitversion -output file 42 | git add GitVersion.json 43 | ``` 44 | 45 | ### 4. Installing GodotVersion Plugin 46 | 47 | Finally, you'll need to install the GodotVersion plugin from the Godot Asset Library. To do this, launch Godot, go to the Asset Library tab, and search for `GodotVersion`. 48 | 49 | Once you've found the plugin, click the `Download` button to install it. And that's it! 50 | 51 | The GodotVersion plugin now will automatically manage and track version updates for your Godot projects. 52 | 53 | ## Using in development 54 | 55 | The GodotVersion plugin adds a new `version` property to the `ProjectSettings` object. This property is a `GitVersion.json` file in dictionary format, and it allows you to easily access the current version of your project. 56 | 57 | To access the current project version using the version property, you can use the following code: 58 | 59 | ```gdscript 60 | var current_version = ProjectSettings.get_setting("version") 61 | ``` 62 | 63 | This will assign the current version of the project to the `current_version` variable. You can then use this variable to display the version number in your game in a `Label` Control. 64 | --------------------------------------------------------------------------------