Skip to content

Commit

Permalink
chore: add credits recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Jan 14, 2024
1 parent d63da4d commit b2ac9e4
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
18 changes: 14 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -181,32 +185,38 @@ 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 .)
mv {{ build_dir }}/windows/{{ game_name }}-windows-v{{ game_version }}.zip {{ dist_dir }}/{{ game_name }}-windows-v{{ game_version }}.zip
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 .)
mv {{ build_dir }}/linux/{{ game_name }}-linux-v{{ game_version }}.zip {{ dist_dir }}/{{ game_name }}-linux-v{{ game_version }}.zip
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

Expand Down
4 changes: 2 additions & 2 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
63 changes: 63 additions & 0 deletions generate_credits.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b2ac9e4

Please sign in to comment.