From 9ff775e2f1a5475b40fcb1711385449685ec6fcd Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD <90267658+Loup-Garou911XD@users.noreply.github.com> Date: Wed, 10 Dec 2025 19:38:03 +0530 Subject: [PATCH 1/2] cleanup --- .github/workflows/release.yml | 4 ++-- README.md | 2 +- test/auto_apply_plugin_metadata.py | 14 ++++++++------ test/{get_changes.py => get_changelog.py} | 0 test/{version_is_lower.py => versioning_tools.py} | 9 ++++++--- 5 files changed, 17 insertions(+), 12 deletions(-) rename test/{get_changes.py => get_changelog.py} (100%) rename test/{version_is_lower.py => versioning_tools.py} (79%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59d8dd8..6db088c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,11 +30,11 @@ jobs: output1=$(python3 test/get_latest.py get_latest_plugman_version) { echo "changelog<> "$GITHUB_OUTPUT" output2=$(python3 test/get_latest.py get_latest_api) - output3=$(python3 test/version_is_lower.py ${{ steps.previoustag.outputs.tag }}) + output3=$(python3 test/versioning_tools.py ${{ steps.previoustag.outputs.tag }}) echo "latestVersion=$output1" >> $GITHUB_OUTPUT echo "latestAPI=$output2" >> $GITHUB_OUTPUT echo "shouldRun=$output3" >> $GITHUB_OUTPUT diff --git a/README.md b/README.md index 6907fa7..cda60d3 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ class Main(babase.Plugin): ``` You'll have to fork this repository and add your `sample_plugin.py` plugin file into the appropriate directory, which for -utility plugin is [plugins/utilities](plugins/utilities). After that, plugin getails and version values will automatically be populated through github-actions in [plugins/utilities.json](plugins/utilities.json)(along with formatting your code as per PEP8 style +utility plugin is [plugins/utilities](plugins/utilities). After that, plugin details and version values will automatically be populated through github-actions in [plugins/utilities.json](plugins/utilities.json)(along with formatting your code as per PEP8 style guide) once you open a pull request. ### Updating a Plugin diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index e694434..a88e48f 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -1,7 +1,9 @@ import sys import json import ast +import os import get_latest +import versioning_tools DEBUG = True @@ -11,7 +13,7 @@ def debug_print(*args, **kwargs): print(*args, **kwargs) -def get_latest_version(plugin_name, category): +def get_latest_version(plugin_name, category) -> str: filepaths = { "minigames": "plugins/minigames.json", "utilities": "plugins/utilities.json", @@ -49,8 +51,8 @@ def update_plugin_json(plugin_info, category): try: # Check if plugin is already in the json plugin = data["plugins"][name] - plugman_version = int(get_latest_version(name, category).replace(".", "")) - current_version = int(plugin_info["version"].replace(".", "")) + plugman_version = int(versioning_tools.semantic_to_str(get_latest_version(name, category))) + current_version = int(versioning_tools.semantic_to_str(plugin_info["version"])) # Ensure the version is always greater from the already released version if current_version > plugman_version: plugin["versions"][plugin_info["version"]] = None @@ -77,13 +79,13 @@ def update_plugin_json(plugin_info, category): def extract_plugman(plugins): for plugin in plugins: - if "plugins/" in plugin: + if "plugins"+os.sep in plugin and plugin.endswith(".py"): debug_print(plugin) try: # Split the path and get the part after 'plugins/' - parts = plugin.split("plugins/")[1].split("/") - file_name_no_extension = plugin.split("/")[-1].replace(".py", "") + parts = plugin.split("plugins"+os.sep)[1].split(os.sep) + file_name_no_extension = plugin.split(os.sep)[-1].replace(".py", "") category = parts[0] # First part after plugins/ except ValueError: if "plugin_manager" in plugin: diff --git a/test/get_changes.py b/test/get_changelog.py similarity index 100% rename from test/get_changes.py rename to test/get_changelog.py diff --git a/test/version_is_lower.py b/test/versioning_tools.py similarity index 79% rename from test/version_is_lower.py rename to test/versioning_tools.py index 8b6f429..b2facfd 100644 --- a/test/version_is_lower.py +++ b/test/versioning_tools.py @@ -1,16 +1,19 @@ import sys from get_latest import get_latest_version +"""if called directly from command line, it will check if given version is lower +than latest version in index.json""" + def semantic_to_str(semantic_version: str): """Convert version in the form of v1.2.3 to 001002003 for comparing 2 version in semantic versioning format""" out = "" - for i in (semantic_version.split(".")): + for i in semantic_version.split("."): if len(i) == 1: - out += "00"+i + out += "00" + i if len(i) == 2: - out += "0"+i + out += "0" + i return out From 49a4c43830db79aee5ae1b69577adc6de45a1bcb Mon Sep 17 00:00:00 2001 From: Loup-Garou911XD <90267658+Loup-Garou911XD@users.noreply.github.com> Date: Wed, 10 Dec 2025 14:08:42 +0000 Subject: [PATCH 2/2] [ci] apply-plugin-metadata-and-formatting --- test/auto_apply_plugin_metadata.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index a88e48f..9e94659 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -51,7 +51,8 @@ def update_plugin_json(plugin_info, category): try: # Check if plugin is already in the json plugin = data["plugins"][name] - plugman_version = int(versioning_tools.semantic_to_str(get_latest_version(name, category))) + plugman_version = int(versioning_tools.semantic_to_str( + get_latest_version(name, category))) current_version = int(versioning_tools.semantic_to_str(plugin_info["version"])) # Ensure the version is always greater from the already released version if current_version > plugman_version: