diff --git a/Justfile b/Justfile index 0b5a9ed..f4548b9 100644 --- a/Justfile +++ b/Justfile @@ -141,6 +141,10 @@ fmt: just venv pip install pre-commit==3.* just venv pre-commit run -a +# Generate the CREDTIS.md file +credits: + just venv python ./generate_credits.py + # === Godot === # # Recipes around the Godot binary. @@ -181,12 +185,18 @@ butler *ARGS: check-butler sed -i "s,application/version=.*$,application/version=\"{{ game_version }}\",g" ./export_presets.cfg sed -i "s,application/short_version=.*$,application/short_version=\"{{ short_version }}\",g" ./export_presets.cfg + echo "Update version in the project.godot" + sed -i "s,config/version=.*$,config/version=\"{{ game_version }}\",g" ./project.godot + 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 + # Export game on Windows -export-windows: makedirs bump-version install-addons import-resources +export-windows: pre-export mkdir -p {{ build_dir }}/windows just godot --headless --export-release '"Windows Desktop"' {{ build_dir }}/windows/{{ game_name }}.exe (cd {{ build_dir }}/windows && zip {{ game_name }}-windows-v{{ game_version }}.zip -r .) @@ -194,11 +204,11 @@ export-windows: makedirs bump-version install-addons import-resources rm -rf {{ build_dir }}/windows # Export game on MacOS -export-mac: makedirs bump-version install-addons import-resources +export-mac: pre-export just godot --headless --export-release "macOS" {{ dist_dir }}/{{ game_name }}-mac-v{{ game_version }}.zip # Export game on Linux -export-linux: makedirs bump-version install-addons import-resources +export-linux: pre-export mkdir -p {{ build_dir }}/linux just godot --headless --export-release "Linux/X11" {{ build_dir }}/linux/{{ game_name }}.x86_64 (cd {{ build_dir }}/linux && zip {{ game_name }}-linux-v{{ game_version }}.zip -r .) @@ -206,7 +216,7 @@ export-linux: makedirs bump-version install-addons import-resources rm -rf {{ build_dir }}/linux # Export game for the web -export-web: makedirs bump-version install-addons import-resources +export-web: pre-export mkdir -p {{ build_dir }}/web just godot --headless --export-release "Web" {{ build_dir }}/web/index.html diff --git a/export_presets.cfg b/export_presets.cfg index cb341cf..3b2077d 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -35,8 +35,8 @@ application/modify_resources=true application/icon="" application/console_wrapper_icon="" application/icon_interpolation=4 -application/file_version="0.1.2.20231216" -application/product_version="0.1.2.20231216" +application/file_version="0.1.2.20240114" +application/product_version="0.1.2.20240114" application/company_name="Mechanical Flower" application/product_name="GhostSnap" application/file_description="" diff --git a/generate_credits.py b/generate_credits.py new file mode 100755 index 0000000..04dd34c --- /dev/null +++ b/generate_credits.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +import os +from string import Template + + +def main(): + template = Template(( + '- "[$files]($source)" by **$author** licensed' + ' under [$license](./LICENSES/$license.txt)\n' + )) + + deps = {} + section = None + + with open(".reuse/dep5", "r") as file: + for line in file: + if line.startswith('# '): + section = line[len("# "): -1].lower() + + if section is None: + continue + + if line.startswith("Files: "): + if section not in deps: + deps[section] = [] + + deps[section].append({"files": line[len("Files: "):-1]}) + + elif line.startswith("Copyright: "): + if section not in deps: + deps[section] = [] + + date_author = line[len("Copyright: "):-1].split(" ") + date_author.pop(0) + deps[section][-1]["author"] = " ".join(date_author) + + elif line.startswith("License: "): + if section not in deps: + deps[section] = [] + + deps[section][-1]["license"] = line[len("License: "):-1] + + elif line.startswith("Source: "): + if section not in deps: + deps[section] = [] + + deps[section][-1]["source"] = line[len("Source: "):-1] + + if deps: + with open("CREDITS.md", "w") as file: + file.writelines("# Credits\n\n") + + for key, value in deps.items(): + file.writelines(f"## {key.title()}\n") + for dep in value: + file.writelines(template.substitute(**dep)) + else: + if os.path.exists("CREDITS.md"): + os.remove("CREDITS.md") + + +if __name__ == "__main__": + main() diff --git a/project.godot b/project.godot index 2b478ea..2e3be27 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,7 @@ universal_fade/patterns_directory="res://addons/UniversalFade/Patterns" [application] config/name="GhostSnap" +config/version="0.1.2" run/main_scene="res://scenes/gui/menu.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://assets/icon.svg"