diff --git a/circleci/config.yml b/.circleci/config.yml similarity index 100% rename from circleci/config.yml rename to .circleci/config.yml diff --git a/circleci/continue_config.yml b/.circleci/continue_config.yml similarity index 100% rename from circleci/continue_config.yml rename to .circleci/continue_config.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64aea8a1..504004ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,16 +44,28 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.8 - - - name: Update version and tag + + - name: Prepare Dependencies run: | VERSION="${{ steps.bumpr.outputs.next_version }}" - git config user.name "${{ github.actor }}" - git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + # Checkout to PR branch + git checkout ${{ github.head_ref }} git tag -a "$VERSION" -m "Release $VERSION" pip install . - python -m xrfeitoria.utils.publish_plugins update-uplugin-version - python -m xrfeitoria.utils.publish_plugins update-bpy-version + + - name: Update Blender Addon Version + if: "!contains(github.event.pull_request.changed_files, 'src/XRFeitoriaBlender/*')" + run: python -m xrfeitoria.utils.publish_plugins update-uplugin-version + + - name: Update Unreal Plugin Version + if: "!contains(github.event.pull_request.changed_files, 'src/XRFeitoriaUnreal/*')" + run: python -m xrfeitoria.utils.publish_plugins update-uplugin-version + + - name: Update Python Package Version + run: | + python -m xrfeitoria.utils.publish_plugins update-plugin-info git add . - git commit -m "Update version to $VERSION" - git push origin HEAD:main + git commit -m "[bot] Update plugin info" + git push origin ${{ github.head_ref }} diff --git a/src/XRFeitoriaUnreal/XRFeitoriaUnreal.uplugin b/src/XRFeitoriaUnreal/XRFeitoriaUnreal.uplugin index 6726a15a..c4c37dc8 100644 --- a/src/XRFeitoriaUnreal/XRFeitoriaUnreal.uplugin +++ b/src/XRFeitoriaUnreal/XRFeitoriaUnreal.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, "Version": 1, - "VersionName": "0.6.3", + "VersionName": "1.0.0", "FriendlyName": "XRFeitoriaUnreal", "Description": "OpenXRLab Synthetic Data Rendering Toolbox", "Category": "Scripting", diff --git a/xrfeitoria/utils/plugin_infos.json b/xrfeitoria/utils/plugin_infos.json index 55a6f8fa..2939c842 100644 --- a/xrfeitoria/utils/plugin_infos.json +++ b/xrfeitoria/utils/plugin_infos.json @@ -1,4 +1,19 @@ { + "1.0.0": { + "XRFeitoria": "1.0.0", + "XRFeitoriaBpy": "0.6.3", + "XRFeitoriaUnreal": "1.0.0" + }, + "0.7.0": { + "XRFeitoria": "0.7.0", + "XRFeitoriaBpy": "0.6.3", + "XRFeitoriaUnreal": "0.7.0" + }, + "0.6.3": { + "XRFeitoria": "0.6.3", + "XRFeitoriaBpy": "0.6.3", + "XRFeitoriaUnreal": "0.6.3" + }, "0.6.2": { "XRFeitoria": "0.6.2", "XRFeitoriaBpy": "0.6.2", diff --git a/xrfeitoria/utils/publish_plugins.py b/xrfeitoria/utils/publish_plugins.py index ba2256c8..23ab7cb3 100644 --- a/xrfeitoria/utils/publish_plugins.py +++ b/xrfeitoria/utils/publish_plugins.py @@ -3,15 +3,17 @@ >>> python -m xrfeitoria.utils.publish_plugins --help """ +import json import os import platform import re import subprocess from contextlib import contextmanager from pathlib import Path -from typing import List, Optional, Tuple +from typing import Dict, List, Optional, Tuple from loguru import logger +from packaging.version import parse from typer import Option, Typer from ..data_structure.constants import plugin_name_blender, plugin_name_pattern, plugin_name_unreal @@ -24,6 +26,7 @@ src_root = project_root / 'src' dist_root = src_root / 'dist' dist_root.mkdir(exist_ok=True, parents=True) +plugin_infos_json = root / 'plugin_infos.json' setup_logger(level='INFO') app = Typer(pretty_exceptions_show_locals=False) @@ -84,6 +87,28 @@ def _make_archive( return dst_path +@app.command() +def update_plugin_info(): + """Update version infos in plugin files.""" + package_version = str(parse(__version__)) + + bpy_version = (src_root / plugin_name_blender / '__init__.py').read_text() + bpy_version = re.search(r"__version__ = version = '(.*)'", bpy_version).group(1) + + unreal_version = (src_root / plugin_name_unreal / f'{plugin_name_unreal}.uplugin').read_text() + unreal_version = re.search(r'"VersionName": "(.*)"', unreal_version).group(1) + + plugin_infos: Dict[str, Dict[str, str]] = json.loads(plugin_infos_json.read_text()) + plugin_infos[package_version] = { + 'XRFeitoria': package_version, + 'XRFeitoriaBpy': str(parse(bpy_version)), + 'XRFeitoriaUnreal': str(parse(unreal_version)), + } + plugin_infos = dict(sorted(plugin_infos.items(), key=lambda item: parse(item[0]), reverse=True)) # sort by version + plugin_infos_json.write_text(json.dumps(plugin_infos, indent=4) + '\n') # dump to json + logger.info(f'Updated "{plugin_infos_json}" with version {package_version}') + + @app.command() def update_bpy_version(bpy_init_file: Path = src_root / plugin_name_blender / '__init__.py'): """Update version in ``src/XRFeitoriaBpy/__init__.py``. diff --git a/xrfeitoria/utils/runner.py b/xrfeitoria/utils/runner.py index 797b59f8..798a5a0e 100644 --- a/xrfeitoria/utils/runner.py +++ b/xrfeitoria/utils/runner.py @@ -40,7 +40,6 @@ # XXX: hardcode download url dist_root = os.environ.get('XRFEITORIA__DIST_ROOT') or 'https://github.com/openxrlab/xrfeitoria/releases/download' -# plugin_info_url = 'https://openxrlab-share.oss-cn-hongkong.aliyuncs.com/xrfeitoria/plugins/plugin_infos.json' plugin_infos_json = Path(__file__).parent.resolve() / 'plugin_infos.json' plugin_info_type = TypedDict( 'PluginInfo', @@ -503,10 +502,6 @@ def _start_rpc(self, background: bool = True, project_path: Optional[Path] = '') @property @lru_cache def plugin_info(self) -> plugin_info_type: - # if not plugin_infos_json.exists(): - # path = self._download(url=plugin_info_url, dst_dir=plugin_infos_json.parent) - # assert path == plugin_infos_json, f'Failed to download plugin infos to "{plugin_infos_json}"' - # plugin_infos = { "0.5.0": { "XRFeitoria": "0.5.0", "XRFeitoriaBpy": "0.5.0", "XRFeitoriaUnreal": "0.5.0" }, ... } plugin_infos: Dict[str, Dict[str, str]] = json.loads(plugin_infos_json.read_text()) plugin_versions = sorted((map(parse, plugin_infos.keys()))) _version = parse(__version__)