Skip to content

Commit

Permalink
build: add custom exportbuild info
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Feb 4, 2024
1 parent 8ae31e8 commit 6f03c20
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data_*/
.plugged/
addons/*
!addons/gd-plug/
!addons/export-build-info/

# Python-specific ignores
venv/
Expand Down
7 changes: 1 addition & 6 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ game_itchio_key := env_var_or_default('GAME_ITCHIO_KEY', "")
# Build info
datetime := `date '+%Y%m%d'`
short_version := replace_regex(game_version, "([0-9]+).([0-9]+).[0-9]+", "$1.$2")
build_date := `date +'%Y/%m/%d'`
commit_hash := `git log --pretty=format:"%H" -1`

# Python virtualenv
Expand Down Expand Up @@ -194,10 +193,6 @@ butler *ARGS: check-butler
sed -i "s,releases/download/.*/Marble-linux-v.*\.zip$,releases/download/{{ game_version }}/Marble-linux-v{{ game_version }}\.zip,g" ./public/packaging/snap/snapcraft.yaml
sed -i "s,Version=.*$,Version={{ game_version }},g" ./public/packaging/org.mechanicalflower.Marble.desktop

echo "Create the override.cfg"
touch override.cfg
echo -e '[build_info]\npackage/version="{{ game_version }}"\npackage/build_date="{{ build_date }}"\nsource/commit="{{ commit_hash }}"' > override.cfg

[private]
pre-export: clean-addons makedirs bump-version install-addons import-resources

Expand Down Expand Up @@ -237,7 +232,7 @@ export: export-windows export-mac export-linux
# Remove game plugins
clean-addons:
rm -rf .plugged
[ -f plug.gd ] && find addons/ -type d -not -name 'addons' -not -name 'gd-plug' -exec rm -rf {} \; || true
[ -f plug.gd ] && (cd addons/ && git clean -f -X -d) || true

# Remove files created by Godot
clean-resources:
Expand Down
19 changes: 19 additions & 0 deletions addons/export-build-info/build_info.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const BUILD_INFO_VERSION := "application/config/version"
const BUILD_INFO_COMMIT := "custom_options/build_info/commit"
const BUILD_INFO_DATE := "custom_options/build_info/date"


static func setup_build_info_settings():
var output := []

# Commit Hash
OS.execute("git", ["log", '--pretty=format:"%H"', "-1"], output, false)
output[0] = output[0].trim_suffix("\n")
ProjectSettings.set_as_internal(BUILD_INFO_COMMIT, true)
ProjectSettings.set_setting(BUILD_INFO_COMMIT, output[0])

# Datetime
OS.execute("date", ["+%Y/%m/%d"], output, false)
output[1] = output[1].trim_suffix("\n")
ProjectSettings.set_as_internal(BUILD_INFO_DATE, true)
ProjectSettings.set_setting(BUILD_INFO_DATE, output[1])
7 changes: 7 additions & 0 deletions addons/export-build-info/export_plugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends EditorExportPlugin

const BuildInfo := preload("res://addons/export-build-info/build_info.gd")


func _export_begin(_features, _is_debug, _path, _flags) -> void:
BuildInfo.setup_build_info_settings()
15 changes: 15 additions & 0 deletions addons/export-build-info/label.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@tool
extends Label

const BuildInfo := preload("res://addons/export-build-info/build_info.gd")


func _ready():
var build_version = ProjectSettings.get_setting(BuildInfo.BUILD_INFO_VERSION)
var build_commit = ProjectSettings.get_setting(BuildInfo.BUILD_INFO_COMMIT)
var build_date = ProjectSettings.get_setting(BuildInfo.BUILD_INFO_DATE)

if build_version and build_commit and build_date:
set_text("v%s @ %s\n%s" % [build_version, build_commit.left(7), build_date])
else:
set_text("")
7 changes: 7 additions & 0 deletions addons/export-build-info/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="build_info"
description=""
author="florianvazelle"
version="0.0.0"
script="plugin.gd"
17 changes: 17 additions & 0 deletions addons/export-build-info/plugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@tool
extends EditorPlugin

const BuildInfo := preload("res://addons/export-build-info/build_info.gd")

var export_plugin := preload("res://addons/export-build-info/export_plugin.gd").new()


func _enter_tree():
add_export_plugin(export_plugin)

if Engine.is_editor_hint():
BuildInfo.setup_build_info_settings()


func _exit_tree():
remove_export_plugin(export_plugin)
12 changes: 6 additions & 6 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="override.cfg"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
Expand Down Expand Up @@ -35,8 +35,8 @@ application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version="1.4.6.20240114"
application/product_version="1.4.6.20240114"
application/file_version="1.4.6.20240204"
application/product_version="1.4.6.20240204"
application/company_name="Mechanical Flower"
application/product_name="Marble"
application/file_description=""
Expand Down Expand Up @@ -70,7 +70,7 @@ runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="override.cfg"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
Expand Down Expand Up @@ -110,7 +110,7 @@ runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="override.cfg"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
Expand Down Expand Up @@ -217,7 +217,7 @@ runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter="override.cfg"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
Expand Down
7 changes: 6 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ SettingsManager="*res://scripts/framework/settings_manager.gd"
Shake="*res://scripts/shake.gd"
DebugMenu="*res://addons/debug_menu/debug_menu.tscn"

[custom_options]

build_info/commit="8ae31e80beb2a3f9b2f8682c2e6488e90aa01de9"
build_info/date="2024/02/04"

[display]

window/stretch/mode="viewport"
Expand All @@ -40,7 +45,7 @@ window/size/height=720

[editor_plugins]

enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg", "res://addons/coi_serviceworker/plugin.cfg")
enabled=PackedStringArray("res://addons/coi_serviceworker/plugin.cfg", "res://addons/debug_menu/plugin.cfg", "res://addons/export-build-info/plugin.cfg")

[filesystem]

Expand Down
13 changes: 7 additions & 6 deletions scenes/gui/menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://scripts/gui/menu.gd" id="1"]
[ext_resource type="FontFile" uid="uid://cpxtqija5l465" path="res://assets/fonts/box_pixies.ttf" id="2"]
[ext_resource type="AudioStream" uid="uid://befsdykgrnt25" path="res://assets/sounds/sfx/ui_open.wav" id="3"]
[ext_resource type="Script" path="res://scripts/gui/build_info.gd" id="4"]
[ext_resource type="Script" path="res://addons/export-build-info/label.gd" id="3_3g7a0"]

[sub_resource type="LabelSettings" id="LabelSettings_wpgwf"]
font = ExtResource("2")
Expand Down Expand Up @@ -95,13 +95,14 @@ text = "Quit"
[node name="Spacer3" type="Control" parent="StartMenu/VBoxContainer"]
layout_mode = 2

[node name="CenterContainer" type="CenterContainer" parent="StartMenu/VBoxContainer"]
layout_mode = 2

[node name="BuildInfo" type="Label" parent="StartMenu/VBoxContainer/CenterContainer"]
[node name="BuildInfo" type="Label" parent="StartMenu/VBoxContainer"]
modulate = Color(1, 1, 1, 0.498039)
layout_mode = 2
script = ExtResource("4")
text = "v1.4.6 @ 8ae31e8
2024/02/04"
horizontal_alignment = 1
vertical_alignment = 1
script = ExtResource("3_3g7a0")

[node name="PauseMenu" type="ColorRect" parent="."]
unique_name_in_owner = true
Expand Down
12 changes: 0 additions & 12 deletions scripts/gui/build_info.gd

This file was deleted.

0 comments on commit 6f03c20

Please sign in to comment.