diff --git a/.gitattributes b/.gitattributes index 4ac4a23..dd8a1d7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,11 @@ +# Properly detect languages on Github. +*.gd linguist-language=GDScript + # Normalize EOL for all files that Git considers text files. * text=auto eol=lf -*.gd linguist-language=GDScript + +# The above only works properly for Git 2.10+, so for older versions +# we need to manually list the binary files we don't want modified. +*.mp3 binary +*.png binary *.hdr binary diff --git a/.github/renovate.json b/.github/renovate.json index 9d107f8..2ac8048 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -3,7 +3,7 @@ { "fileMatch": ["^plug\\.gd$"], "matchStrings": [ - "\\s+plug\\(\"(?.*?)\",\\ \\{\\s*\"commit\":\\ \"(?)(?.*)\"" + "\\s+plug\\(\"(?.*?)\",\\ \\{\\s*\"commit\":\\ \"(?.*)\",\\s*\"renovate-branch\":\\ \"(?.*)\"" ], "depNameTemplate": "{{{gitUrl}}}", "packageNameTemplate": "https://github.com/{{{gitUrl}}}", diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index d1bbb40..644f7c2 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -1,10 +1,11 @@ name: Link Checker + on: - push: + pull_request: + types: [opened, edited, review_requested, synchronize, reopened, ready_for_review, labeled, unlabeled] jobs: linkchecker: - runs-on: ubuntu-latest steps: diff --git a/.github/workflows/lint_pr_title.yml b/.github/workflows/lint_pr_title.yml index 405408f..8ed41cb 100644 --- a/.github/workflows/lint_pr_title.yml +++ b/.github/workflows/lint_pr_title.yml @@ -2,10 +2,7 @@ name: Lint PR Title on: pull_request_target: - types: - - opened - - edited - - synchronize + types: [opened, edited, synchronize] permissions: pull-requests: read diff --git a/.github/workflows/release-packaging.yml b/.github/workflows/release-packaging.yml index fd44411..40a4d60 100644 --- a/.github/workflows/release-packaging.yml +++ b/.github/workflows/release-packaging.yml @@ -68,6 +68,9 @@ jobs: - uses: actions/checkout@v4 - uses: extractions/setup-just@v1 + - name: Load dotenv + run: just ci-load-dotenv + - name: Cache Godot uses: actions/cache@v4 with: @@ -76,9 +79,6 @@ jobs: ~/.local/share/godot/export_templates key: ${{ env.godot_version }} - - name: Load dotenv - run: just ci-load-dotenv - - name: Export run: just export-web diff --git a/.github/workflows/snapcraft-build.yaml b/.github/workflows/snapcraft-build.yaml index ef26b10..7850967 100644 --- a/.github/workflows/snapcraft-build.yaml +++ b/.github/workflows/snapcraft-build.yaml @@ -1,8 +1,15 @@ name: Snapcraft Build on: - push: workflow_dispatch: + # Ensure the build works on main + push: + branches: [main] + # Ensure the build works on each pull request + pull_request: + # Build and publish on release + release: + types: [published] jobs: build: @@ -22,9 +29,9 @@ jobs: path: public/packaging id: snapcraft - # Push, on each tag, to the stable channel + # Push, on each release, to the stable channel - uses: snapcore/action-publish@v1 - if: startsWith(github.ref, 'refs/tags/') + if: ${{ env.GITHUB_EVENT_NAME == 'release' }} env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }} with: diff --git a/.gitignore b/.gitignore index be48c14..57ca861 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ data_*/ .plugged/ addons/* !addons/gd-plug/ +!addons/export-build-info/ # Python-specific ignores venv/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22be8cd..c05084e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,8 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: + - id: check-added-large-files # Prevent giant files from being committed + args: ['--maxkb=1500'] - id: fix-byte-order-marker # Prevents weird UTF-8 encoding edge cases - id: check-case-conflict # Check if case-insensitive filesystems would bork - id: check-docstring-first # Check for if docstring was misplaced @@ -30,8 +32,8 @@ repos: exclude: '^addons/gd-plug/' - repo: local hooks: - - id: lower-case-only - name: lower case only + - id: check-filenames-are-lowercase + name: check that filenames are lowercase entry: filenames must be lower-case or lower_case only language: fail files: '[^a-z0-9._/-]' @@ -39,7 +41,7 @@ repos: (?x)^( .godot/| .reuse/| - addons/| + addons/gd-plug/| CHANGELOG.md| CONTRIBUTING.md| CREDITS.md| @@ -49,8 +51,8 @@ repos: public/| README.md ) - - id: check-shaders - name: check shaders + - id: format-shaders + name: format shaders entry: clang-format args: - --style=llvm @@ -58,4 +60,4 @@ repos: - -i language: system files: \.gdshader$ - exclude: ^addons/ + exclude: ^addons/gd-plug/ diff --git a/.reuse/dep5 b/.reuse/dep5 index c3b10eb..c585e57 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -24,6 +24,11 @@ Copyright: 2019 Tomek License: MIT Source: https://github.com/KoBeWi/Godot-Universal-Fade +Files: addons/coi_serviceworker/* +Copyright: 2023 nisovin +License: MIT +Source: https://github.com/nisovin/godot-coi-serviceworker + # Models Files: assets/blocks/* diff --git a/CHANGELOG.md b/CHANGELOG.md index f92a936..fbba5a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Use a custom `EditorExportPlugin` to set build info ([#41](https://github.com/MechanicalFlower/Marble/pull/41)) ### Security ### Dependencies - Bump `actions/cache` from 3 to 4 ([#40](https://github.com/MechanicalFlower/Marble/pull/40)) diff --git a/CREDITS.md b/CREDITS.md index 8be6560..24dcd45 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -4,6 +4,7 @@ - "[addons/gd-plug/*](https://github.com/imjp94/gd-plug)" by **Tan Jian Ping** licensed under [MIT](./LICENSES/MIT.txt) - "[addons/debug_menu/*](https://github.com/godot-extended-libraries/godot-debug-menu)" by **Hugo Locurcio and contributors** licensed under [MIT](./LICENSES/MIT.txt) - "[addons/UniversalFade/*](https://github.com/KoBeWi/Godot-Universal-Fade)" by **Tomek** licensed under [MIT](./LICENSES/MIT.txt) +- "[addons/coi_serviceworker/*](https://github.com/nisovin/godot-coi-serviceworker)" by **nisovin** licensed under [MIT](./LICENSES/MIT.txt) ## Models - "[assets/blocks/*](https://github.com/Zylann/marbles)" by **Zylann** licensed under [MIT](./LICENSES/MIT.txt) ## Textures diff --git a/Justfile b/Justfile index 5396b7f..ff76415 100644 --- a/Justfile +++ b/Justfile @@ -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 @@ -71,7 +70,7 @@ butler_platform := if arch() == "x86" { "linux-386" } else { if arch() == "x86_6 # Display all commands @default: - echo "OS: {{ os() }} - ARCH: {{ arch() }}\n" + echo -e "OS: {{ os() }} - ARCH: {{ arch() }}\n" just --list # Create directories @@ -88,7 +87,7 @@ butler_platform := if arch() == "x86" { "linux-386" } else { if arch() == "x86_6 # Download Godot [private] install-godot: makedirs - curl -L --silent -X GET "https://github.com/godotengine/godot-builds/releases/download/{{ godot_version }}/{{ godot_filename }}.zip" --output {{ cache_dir }}/{{ godot_filename }}.zip + curl -L --progress-bar -X GET "https://github.com/godotengine/godot-builds/releases/download/{{ godot_version }}/{{ godot_filename }}.zip" --output {{ cache_dir }}/{{ godot_filename }}.zip unzip -o {{ cache_dir }}/{{ godot_filename }}.zip -d {{ cache_dir }} cp {{ cache_dir }}/{{ godot_filename }} {{ godot_bin }} @@ -100,7 +99,7 @@ install-godot: makedirs # Download Godot export templates [private] install-templates: makedirs - curl -L --silent -X GET "https://github.com/godotengine/godot-builds/releases/download/{{ godot_version }}/{{ godot_template }}" --output {{ cache_dir }}/{{ godot_template }} + curl -L --progress-bar -X GET "https://github.com/godotengine/godot-builds/releases/download/{{ godot_version }}/{{ godot_template }}" --output {{ cache_dir }}/{{ godot_template }} unzip -o {{ cache_dir }}/{{ godot_template }} -d {{ cache_dir }} mkdir -p {{ godot_templates_dir }} cp {{ cache_dir }}/templates/* {{ godot_templates_dir }} @@ -133,7 +132,7 @@ export PIP_REQUIRE_VIRTUALENV := "true" # Python virtualenv wrapper [private] @venv *ARGS: - [ ! -d {{ venv_dir }} ] && python3 -m venv {{ venv_dir }} || true + [ ! -d {{ venv_dir }} ] && python3 -m venv {{ venv_dir }} && touch {{ venv_dir }}/.gdignore || true . {{ venv_dir }}/bin/activate && {{ ARGS }} # Run files formatters @@ -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 @@ -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: diff --git a/addons/export-build-info/build_info.gd b/addons/export-build-info/build_info.gd new file mode 100644 index 0000000..c4bc315 --- /dev/null +++ b/addons/export-build-info/build_info.gd @@ -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]) diff --git a/addons/export-build-info/export_plugin.gd b/addons/export-build-info/export_plugin.gd new file mode 100644 index 0000000..a1db813 --- /dev/null +++ b/addons/export-build-info/export_plugin.gd @@ -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() diff --git a/addons/export-build-info/label.gd b/addons/export-build-info/label.gd new file mode 100644 index 0000000..9048772 --- /dev/null +++ b/addons/export-build-info/label.gd @@ -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("") diff --git a/addons/export-build-info/plugin.cfg b/addons/export-build-info/plugin.cfg new file mode 100644 index 0000000..c89fddd --- /dev/null +++ b/addons/export-build-info/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="build_info" +description="" +author="florianvazelle" +version="0.0.0" +script="plugin.gd" diff --git a/addons/export-build-info/plugin.gd b/addons/export-build-info/plugin.gd new file mode 100644 index 0000000..3d3b081 --- /dev/null +++ b/addons/export-build-info/plugin.gd @@ -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) diff --git a/export_presets.cfg b/export_presets.cfg index 255b069..2a6bb0e 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -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="" @@ -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="" @@ -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="" @@ -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="" @@ -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="" diff --git a/plug.gd b/plug.gd index 0fefd45..a410a80 100644 --- a/plug.gd +++ b/plug.gd @@ -4,7 +4,13 @@ extends "res://addons/gd-plug/plug.gd" func _plugging(): plug( "godot-extended-libraries/godot-debug-menu", - {"commit": "9d36ea23661d095198ff7fcfff2715172f73c983"} + {"commit": "9d36ea23661d095198ff7fcfff2715172f73c983", "renovate-branch": "master"} + ) + plug( + "KoBeWi/Godot-Universal-Fade", + {"commit": "f091514bba652880f81c5bc8809e0ee4498988ea", "renovate-branch": "master"} + ) + plug( + "nisovin/godot-coi-serviceworker", + {"commit": "de1be2989eda4c7d77a08b8c56cd94c769181c4e", "renovate-branch": "main"} ) - plug("KoBeWi/Godot-Universal-Fade", {"commit": "f091514bba652880f81c5bc8809e0ee4498988ea"}) - plug("nisovin/godot-coi-serviceworker", {"commit": "de1be2989eda4c7d77a08b8c56cd94c769181c4e"}) diff --git a/project.godot b/project.godot index 08685e5..a9e18e6 100644 --- a/project.godot +++ b/project.godot @@ -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" @@ -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] diff --git a/scenes/gui/menu.tscn b/scenes/gui/menu.tscn index 0c02ca1..ed17a4f 100644 --- a/scenes/gui/menu.tscn +++ b/scenes/gui/menu.tscn @@ -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") @@ -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 diff --git a/scripts/gui/build_info.gd b/scripts/gui/build_info.gd deleted file mode 100644 index a2d8152..0000000 --- a/scripts/gui/build_info.gd +++ /dev/null @@ -1,12 +0,0 @@ -@tool - -extends Label - - -func _ready(): - var build_version = ProjectSettings.get_setting("build_info/package/version") - var build_commit = ProjectSettings.get_setting("build_info/source/commit") - if build_version and build_commit: - set_text("v" + build_version + "@" + build_commit.left(7)) - else: - set_text("")