Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.1 #44

Merged
merged 18 commits into from
Jan 4, 2025
Merged

v2.1 #44

112 changes: 112 additions & 0 deletions .github/workflows/Pyinstaller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Build and Release

on:
push:
branches:
- dev
- master
paths:
- 'pyproject.toml'

permissions:
contents: write
actions: write
jobs:
build:
runs-on: windows-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Get Version from pyproject.toml
id: get-version
run: |
$version = (Get-Content pyproject.toml | Select-String -Pattern '^version = "(.*)"' | ForEach-Object { $_.Matches.Groups[1].Value })
echo "version=$version" >> $env:GITHUB_ENV
echo "version=$version" >> $env:GITHUB_OUTPUT

- name: Get Last Commit Version
run: |
$commit_version = (git show HEAD^:pyproject.toml | Select-String -Pattern '^version = "(.*)"' | ForEach-Object { $_.Matches.Groups[1].Value })
if (!$commit_version) { $commit_version = "none" }
echo "last_commit_version=$commit_version" >> $env:GITHUB_ENV

- name: Check if Versions Match
run: |
if ("${{ env.version }}" -eq "${{ env.last_commit_version }}") {
echo "skip_build=true" >> $env:GITHUB_ENV
} else {
echo "skip_build=false" >> $env:GITHUB_ENV
}

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
if: env.skip_build != 'true'

- name: Install PDM
run: pip install pdm
if: env.skip_build != 'true'

- name: Install Dependencies
run: |
pdm install
pip install pyinstaller
if: env.skip_build != 'true'

- name: Build Binary with PyInstaller
run: |
$env:PYTHONPATH = ".\.venv\Lib\site-packages"; pyinstaller --name GameYamlSpider `
--add-data "gameyamlspiderandgenerator\plugin:gameyamlspiderandgenerator\plugin" `
--add-data "./.venv/lib/site-packages/language_data/data:language_data\data" `
--add-data ./.venv/lib/site-packages/ruamel/yaml/string/__plug_in__.py:ruamel/yaml/string `
--hidden-import gameyamlspiderandgenerator.plugin.gcores `
--hidden-import gameyamlspiderandgenerator.plugin.itchio `
--hidden-import gameyamlspiderandgenerator.plugin.steam `
--hidden-import yamlgenerator_hook_search `
--hidden-import language_data `
--hidden-import ruamel.yaml.string `
--hidden-import yamlgenerator_hook_validate `
pkg.py
env:
PATH: ${{ github.workspace }}/.pdm/bin:${{ env.PATH }}
if: env.skip_build != 'true'

- name: Package with Zipfile
run: python -m zipfile -c dist\GameYamlSpider.zip dist\GameYamlSpider
if: env.skip_build != 'true'

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: GameYamlSpider-zip
path: dist/GameYamlSpider.zip
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Set Is Pre-release
id: prerelease-check
run: |
version="${{ needs.build.outputs.version }}"
echo "version=$version" >> $GITHUB_ENV
if [[ "$version" =~ (a|b|dev|rc)\d? ]]; then
echo "This is a pre-release version. Skipping GitHub release."
exit 1
else
echo "This is a stable release."
fi
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: GameYamlSpider-zip
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: GameYamlSpider.zip
tag_name: v${{ env.version }}
target_commitish: ${{ github.ref }}
2 changes: 1 addition & 1 deletion .github/workflows/Test Default Hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master
paths:
- '**.py'
- '**.yml'
- 'Test*.yml'
- '**.lock'
- '**.yaml'
permissions:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/Test Main Program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master
paths:
- '**.py'
- '**.yml'
- 'Test*.yml'
- '**.lock'
- '**.yaml'
permissions:
Expand All @@ -18,19 +18,23 @@ jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.11, 3.12, 3.13]

steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: 3.11
python-version: ${{ matrix.python-version }}
cache: true
- name: Check Cache
id: cache-check
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pdm.lock') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pdm.lock') }}
- name: Install dependencies
if: steps.cache-check.outputs.cache-hit != 'true'
run: pdm install
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
__pycache__
dist
tests/Atopes.zip
tests/Springblades.zip
tests/Springblades.zip
/managed_context/
/gameyamlspiderandgenerator.egg-info/
/test_suite_analysis/
/build/
2 changes: 1 addition & 1 deletion gameyamlspiderandgenerator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger.add(sys.stdout, level="WARNING")


def verify(url: str) -> Callable[..., BasePlugin] | None:
def verify(url: str) -> Callable[..., type[BasePlugin]] | None:
if not pkg.plugin:
raise PluginNotLoadedError
verify_list = [
Expand Down
5 changes: 3 additions & 2 deletions gameyamlspiderandgenerator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from loguru import logger
from yaml import safe_load

from gameyamlspiderandgenerator import produce_yaml
from . import produce_yaml
from .util.config import config
from .util.fgi import default_config
from .util.fgi_yaml import get_valid_filename
Expand Down Expand Up @@ -65,6 +65,7 @@
if args.silent:
logger.remove()
logger.debug(sys.version)
logger.debug(" ".join(sys.argv))
logger.debug("version: " + version("gameyamlspiderandgenerator"))
if isinstance(args.config, str):
with open(args.config) as f:
Expand All @@ -87,7 +88,7 @@ def getenv_case_insensitive(key):
"http": getenv_case_insensitive("HTTP_PROXY"),
"https": getenv_case_insensitive("HTTPS_PROXY"),
}
config.update(setting)
config.load(setting)
pkg.init()
yml = produce_yaml(args.url, args.lang)
if args.output is None:
Expand Down
6 changes: 3 additions & 3 deletions gameyamlspiderandgenerator/hook/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HookLoadingSequence(Enum):


class BaseHook(abc.ABC):
"""钩子基类"""
"""Base class for hooks"""

CHANGED: list | None = None
REQUIRE_CONFIG: bool = False
Expand All @@ -18,8 +18,8 @@ class BaseHook(abc.ABC):
@abc.abstractmethod
def setup(self, data: dict):
"""
运行钩子函数
Run the hook function

Args:
data: 数据
data: The data
"""
Loading
Loading