Skip to content

Commit

Permalink
Test (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
HaiyiMei and github-actions[bot] authored Jun 25, 2024
1 parent 2df702a commit 8397e7f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 15 deletions.
File renamed without changes.
File renamed without changes.
28 changes: 20 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion src/XRFeitoriaUnreal/XRFeitoriaUnreal.uplugin
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 15 additions & 0 deletions xrfeitoria/utils/plugin_infos.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
27 changes: 26 additions & 1 deletion xrfeitoria/utils/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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``.
Expand Down
5 changes: 0 additions & 5 deletions xrfeitoria/utils/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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__)
Expand Down

0 comments on commit 8397e7f

Please sign in to comment.